autoroutes


Nameautoroutes JSON
Version 0.3.7 PyPI version JSON
download
home_pagehttps://github.com/pyrates/autoroutes
SummaryRoutes for speed
upload_time2024-02-21 10:25:21
maintainer
docs_urlNone
authorYohan Boniface
requires_python
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            # Autoroutes

Routes for speed.


## Install

    pip install autoroutes


## API

```python
# 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

![](https://raw.githubusercontent.com/pyrates/autoroutes/master/benchmark.png)

See [Benchmark](https://github.com/pyrates/autoroutes/wiki/Benchmark) for more
details.

## Acknowledgements

This package has been first made as a Cython port of the [R3](https://github.com/c9s/r3/)
C router.
See also [python-r3](https://framagit.org/ybon/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.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/pyrates/autoroutes",
    "name": "autoroutes",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Yohan Boniface",
    "author_email": "yohan.boniface@data.gouv.fr",
    "download_url": "https://files.pythonhosted.org/packages/71/2a/47d9b1d25ce3017416ba7e1565bf2f07f606d0d7121dc45c476985db601f/autoroutes-0.3.7.tar.gz",
    "platform": "POSIX",
    "description": "# Autoroutes\n\nRoutes for speed.\n\n\n## Install\n\n    pip install autoroutes\n\n\n## API\n\n```python\n# Create a Routes instance\nfrom autoroutes import Routes\nroutes = Routes()\n\n# Register a new route\nroutes.add('path/to/resource/{id}', something='value', anything='else')\n\n# Try to match a route\nroutes.match('path/to/resource/1234')\n> ({'something': 'value', 'anything': 'else'}, {'id': '1234'})\n```\n\nNote: the order the routes are registered matters. At match time, routes will be\ntried in that order.\n\n### Placeholders\n\nPlaceholders are defined by a curly brace pair: `path/{var}`. By default, this\nwill match any character but the slash ('/').\n\nIt's possible to control the placeholder type, either by:\n- using a named type: `alnum`, `digit`, `alpha`, `path` (matches everything),\n  `any` (matches everything, including empty string), `string` (default):\n\n        path/to/{var:digit}\n        path/to/{var:string}  # Same as path/to/{var}\n\n- using a normal regex (slower; also note that regex containing curly braces is\n  not yet supported)\n\n        path/to/{var:\\d\\d\\d}\n\nPlaceholders can appear anywhere in the path\n\n    path/to/file.{ext}\n    path/to/{name}.{ext}\n\n\n## Building from source\n\n    pip install cython\n    make compile\n    python setup.py develop\n\n\n## Tests\n\n    make test\n\n## Benchmark\n\n![](https://raw.githubusercontent.com/pyrates/autoroutes/master/benchmark.png)\n\nSee [Benchmark](https://github.com/pyrates/autoroutes/wiki/Benchmark) for more\ndetails.\n\n## Acknowledgements\n\nThis package has been first made as a Cython port of the [R3](https://github.com/c9s/r3/)\nC router.\nSee also [python-r3](https://framagit.org/ybon/python-r3), which was a first\nattempt to wrap R3. I was unhappy with the stability, and more curious about\nCython, so I tried to make a first POC port, and was happy with it.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Routes for speed",
    "version": "0.3.7",
    "project_urls": {
        "Homepage": "https://github.com/pyrates/autoroutes"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "712a47d9b1d25ce3017416ba7e1565bf2f07f606d0d7121dc45c476985db601f",
                "md5": "46cedc2f94ab6e8b3ee84361cbadafbd",
                "sha256": "03ab8d7c750dd01b1ef816446416fa34290b5b595582eefb8d166040e92991e2"
            },
            "downloads": -1,
            "filename": "autoroutes-0.3.7.tar.gz",
            "has_sig": false,
            "md5_digest": "46cedc2f94ab6e8b3ee84361cbadafbd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 118805,
            "upload_time": "2024-02-21T10:25:21",
            "upload_time_iso_8601": "2024-02-21T10:25:21.182962Z",
            "url": "https://files.pythonhosted.org/packages/71/2a/47d9b1d25ce3017416ba7e1565bf2f07f606d0d7121dc45c476985db601f/autoroutes-0.3.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-21 10:25:21",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "pyrates",
    "github_project": "autoroutes",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": false,
    "lcname": "autoroutes"
}
        
Elapsed time: 0.31160s