diff --git a/docs/sanic/routing.md b/docs/sanic/routing.md index e039e249..f1882684 100644 --- a/docs/sanic/routing.md +++ b/docs/sanic/routing.md @@ -214,3 +214,28 @@ and `recv` methods to send and receive data respectively. WebSocket support requires the [websockets](https://github.com/aaugustin/websockets) 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) +``` diff --git a/sanic/blueprints.py b/sanic/blueprints.py index b899481b..235fe909 100644 --- a/sanic/blueprints.py +++ b/sanic/blueprints.py @@ -23,6 +23,7 @@ class Blueprint: :param name: unique name of the blueprint :param url_prefix: URL to be prefixed before all route URLs + :param strict_slashes: strict to trailing slash """ self.name = name self.url_prefix = url_prefix