Merge pull request #556 from AntonDnepr/fix-414

Small changes to the docs and tests for the #414
This commit is contained in:
Raphael Deem 2017-03-14 21:07:55 -07:00 committed by GitHub
commit e92f1b8c28
2 changed files with 22 additions and 4 deletions

View File

@ -48,6 +48,24 @@ app.add_route(SimpleView.as_view(), '/')
```
You can also use `async` syntax.
```python
from sanic import Sanic
from sanic.views import HTTPMethodView
from sanic.response import text
app = Sanic('some_name')
class SimpleAsyncView(HTTPMethodView):
async def get(self, request):
return text('I am async get method')
app.add_route(SimpleAsyncView.as_view(), '/')
```
## URL parameters
If you need any URL parameters, as discussed in the routing guide, include them

View File

@ -15,13 +15,13 @@ def test_methods(method):
class DummyView(HTTPMethodView):
def get(self, request):
async def get(self, request):
return text('', headers={'method': 'GET'})
def post(self, request):
return text('', headers={'method': 'POST'})
def put(self, request):
async def put(self, request):
return text('', headers={'method': 'PUT'})
def head(self, request):
@ -30,7 +30,7 @@ def test_methods(method):
def options(self, request):
return text('', headers={'method': 'OPTIONS'})
def patch(self, request):
async def patch(self, request):
return text('', headers={'method': 'PATCH'})
def delete(self, request):