add blueprint name to request.endpoint

This commit is contained in:
Raphael Deem
2017-10-16 23:11:56 -07:00
parent 75f2180cb1
commit 9150767574
2 changed files with 33 additions and 2 deletions

View File

@@ -136,3 +136,24 @@ app = Sanic()
def hello(request):
return text(request.endpoint)
```
Or, with a blueprint it will be include both, separated by a period. For example,
the below route would return foo.bar:
```python
from sanic import Sanic
from sanic import Blueprint
from sanic.response import text
app = Sanic(__name__)
blueprint = Blueprint('foo')
@blueprint.get('/')
async def bar(request):
return text(request.endpoint)
app.blueprint(blueprint)
app.run(host="0.0.0.0", port=8000, debug=True)
```