Autoroutes
Routes for speed.
Install
pip install autoroutes
API
# Create a Routes instance
from autoroutes import Routes
routes = Routes()
# Register a new route
routes.add('path/to/resource/{id}', something='value', anything='else')
# Try to match a route
routes.match('path/to/resource/1234')
> ({'something': 'value', 'anything': 'else'}, {'id': '1234'})
Note: the order the routes are registered matters. At match time, routes will be tried in that order.
Placeholders
Placeholders are defined by a curly brace pair: path/{var}. By default, this
will match any character but the slash ('/').
It's possible to control the placeholder type, either by:
-
using a named type:
alnum,digit,alpha,path(matches everything),any(matches everything, including empty string),string(default):path/to/{var:digit} path/to/{var:string} # Same as path/to/{var} -
using a normal regex (slower; also note that regex containing curly braces is not yet supported)
path/to/{var:\d\d\d}
Placeholders can appear anywhere in the path
path/to/file.{ext}
path/to/{name}.{ext}
Building from source
pip install cython
make compile
python setup.py develop
Tests
make test
Benchmark
See Benchmark for more details.
Acknowledgements
This package has been first made as a Cython port of the R3 C router. See also python-r3, which was a first attempt to wrap R3. I was unhappy with the stability, and more curious about Cython, so I tried to make a first POC port, and was happy with it.
Metadata
Release files for autoroutes 0.3.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| autoroutes-0.3.8.tar.gz | 119.1 kB | Without provenance | Details for autoroutes-0.3.8.tar.gz |
Release files / autoroutes-0.3.8.tar.gz
| Download URL | autoroutes-0.3.8.tar.gz |
|---|---|
| Size | 119.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4d2b1874f005c7fc33ac65ee29997e55823237239472e1c16b2c9f3a2bcfed38
|
|
BLAKE2b-256 checksum How to use checksums |
f043c0d11db8ca9c05a81b8d7a80d7576f18ca5b381e721c8566cbc27acce1af
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.13.1
|
Security for autoroutes 0.3.8
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.