diff options
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/narr/urldispatch.rst | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/docs/narr/urldispatch.rst b/docs/narr/urldispatch.rst index 52d64891c..701326fab 100644 --- a/docs/narr/urldispatch.rst +++ b/docs/narr/urldispatch.rst @@ -998,6 +998,24 @@ then only match if the URL path is ``/users/show``, and when the :meth:`pyramid.request.Request.route_url` function is called with the route name ``show_users``, it will generate a URL with that same path. +To create a prefixed route that matches requests to the ``route_prefix`` +without a trailing slash set the route ``pattern`` to an empty string. + +.. code-block:: python + :linenos: + + from pyramid.config import Configurator + + def users_include(config): + config.add_route('show_users', '') + + def main(global_config, **settings): + config = Configurator() + config.include(users_include, route_prefix='/users') + +The above configuration will match ``/users`` instead of ``/users/`` if a slash +had been supplied to the :meth:`pyramid.config.Configurator.add_route` function. + Route prefixes are recursive, so if a callable executed via an include itself turns around and includes another callable, the second-level route prefix will be prepended with the first: |
