Skip to main content

Python wrapper for https://github.com/viz-rs/path-tree

Project description

routrie

CI

A Python wrapper for Rust's path-tree router (path-tree repo, path-tree crate).

This is a blazingly fast HTTP URL router with support for matching path parameters and catch-all URLs.

Usage:

from routrie import Router, Param

# the generic parameter is the value being stored
# normally this will be an endpoint / route instance
router = Router(
  {
    "/users": 1,
    "/users/:id": 2,
    "/user/repo/*any": 3,
  }
)

matched = router.find("/foo-bar-baz")
assert matched is None

matched = router.find("/users/routrie")
assert matched is not None
value, params = matched
assert value == 2
assert params[0].name == "id"
assert params[0].value == "routrie"

matched = router.find("/users")
assert matched is not None
value, params = matched
assert value == 1
assert params == []

matched = router.find("/users/repos/)
assert matched is not None
value, params = matched
assert value == 3
assert params == []

matched = router.find("/users/repos/something)
assert matched is not None
value, params = matched
assert value == 3
assert params[0].name = "any"
assert params[0].value = "something"

Contributing

  1. Clone the repo.
  2. Run make init
  3. Run make test
  4. Make your changes
  5. Push and open a pull request
  6. Wait for CI to run.

If your pull request gets approved and merged, it will automatically be relased to PyPi (every commit to main is released).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

routrie-0.8.0.tar.gz (9.7 kB view hashes)

Uploaded Source

Built Distributions

routrie-0.8.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (207.4 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

routrie-0.8.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (193.8 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

routrie-0.8.0-pp39-pypy39_pp73-macosx_10_7_x86_64.whl (188.9 kB view hashes)

Uploaded PyPy macOS 10.7+ x86-64

routrie-0.8.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (207.1 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

routrie-0.8.0-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (193.7 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

routrie-0.8.0-pp38-pypy38_pp73-macosx_10_7_x86_64.whl (188.8 kB view hashes)

Uploaded PyPy macOS 10.7+ x86-64

routrie-0.8.0-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (209.5 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

routrie-0.8.0-pp37-pypy37_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (195.8 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

routrie-0.8.0-pp37-pypy37_pp73-macosx_10_7_x86_64.whl (190.7 kB view hashes)

Uploaded PyPy macOS 10.7+ x86-64

routrie-0.8.0-cp37-abi3-win_amd64.whl (135.5 kB view hashes)

Uploaded CPython 3.7+ Windows x86-64

routrie-0.8.0-cp37-abi3-win32.whl (131.1 kB view hashes)

Uploaded CPython 3.7+ Windows x86

routrie-0.8.0-cp37-abi3-musllinux_1_2_x86_64.whl (377.6 kB view hashes)

Uploaded CPython 3.7+ musllinux: musl 1.2+ x86-64

routrie-0.8.0-cp37-abi3-musllinux_1_2_i686.whl (402.1 kB view hashes)

Uploaded CPython 3.7+ musllinux: musl 1.2+ i686

routrie-0.8.0-cp37-abi3-musllinux_1_2_armv7l.whl (458.5 kB view hashes)

Uploaded CPython 3.7+ musllinux: musl 1.2+ ARMv7l

routrie-0.8.0-cp37-abi3-musllinux_1_2_aarch64.whl (374.4 kB view hashes)

Uploaded CPython 3.7+ musllinux: musl 1.2+ ARM64

routrie-0.8.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (206.4 kB view hashes)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ x86-64

routrie-0.8.0-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl (260.1 kB view hashes)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ s390x

routrie-0.8.0-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (295.1 kB view hashes)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ ppc64le

routrie-0.8.0-cp37-abi3-manylinux_2_17_ppc64.manylinux2014_ppc64.whl (303.4 kB view hashes)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ ppc64

routrie-0.8.0-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (195.4 kB view hashes)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ ARMv7l

routrie-0.8.0-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (192.8 kB view hashes)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ ARM64

routrie-0.8.0-cp37-abi3-manylinux_2_5_i686.manylinux1_i686.whl (228.8 kB view hashes)

Uploaded CPython 3.7+ manylinux: glibc 2.5+ i686

routrie-0.8.0-cp37-abi3-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (362.3 kB view hashes)

Uploaded CPython 3.7+ macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64

routrie-0.8.0-cp37-abi3-macosx_10_7_x86_64.whl (188.2 kB view hashes)

Uploaded CPython 3.7+ macOS 10.7+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page