This commit is contained in:
Yun Xu 2017-08-21 00:28:01 -07:00
parent 5d23c7644b
commit 63babae63d
2 changed files with 26 additions and 0 deletions

View File

@ -214,3 +214,28 @@ and `recv` methods to send and receive data respectively.
WebSocket support requires the [websockets](https://github.com/aaugustin/websockets) WebSocket support requires the [websockets](https://github.com/aaugustin/websockets)
package by Aymeric Augustin. package by Aymeric Augustin.
## About `strict_slashes`
You can make `routes` strict to trailing slash or not, it's configurable.
```python
# provide default strict_slashes value for all routes
app = Sanic('test_route_strict_slash', strict_slashes=True)
# you can also overwrite strict_slashes value for specific route
@app.get('/get', strict_slashes=False)
def handler(request):
return text('OK')
# It also works for blueprints
bp = Blueprint('test_bp_strict_slash', strict_slashes=True)
@bp.get('/bp/get', strict_slashes=False)
def handler(request):
return text('OK')
app.blueprint(bp)
```

View File

@ -23,6 +23,7 @@ class Blueprint:
:param name: unique name of the blueprint :param name: unique name of the blueprint
:param url_prefix: URL to be prefixed before all route URLs :param url_prefix: URL to be prefixed before all route URLs
:param strict_slashes: strict to trailing slash
""" """
self.name = name self.name = name
self.url_prefix = url_prefix self.url_prefix = url_prefix