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.5.3.tar.gz (8.8 kB view hashes)

Uploaded Source

Built Distributions

routrie-0.5.3-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (187.2 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

routrie-0.5.3-pp39-pypy39_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.whl (199.4 kB view hashes)

Uploaded PyPy manylinux: glibc 2.5+ x86-64

routrie-0.5.3-pp39-pypy39_pp73-macosx_10_7_x86_64.whl (181.5 kB view hashes)

Uploaded PyPy macOS 10.7+ x86-64

routrie-0.5.3-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (187.2 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

routrie-0.5.3-pp38-pypy38_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.whl (199.4 kB view hashes)

Uploaded PyPy manylinux: glibc 2.5+ x86-64

routrie-0.5.3-pp38-pypy38_pp73-macosx_10_7_x86_64.whl (181.3 kB view hashes)

Uploaded PyPy macOS 10.7+ x86-64

routrie-0.5.3-pp37-pypy37_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (188.0 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

routrie-0.5.3-pp37-pypy37_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.whl (201.0 kB view hashes)

Uploaded PyPy manylinux: glibc 2.5+ x86-64

routrie-0.5.3-pp37-pypy37_pp73-macosx_10_7_x86_64.whl (182.8 kB view hashes)

Uploaded PyPy macOS 10.7+ x86-64

routrie-0.5.3-cp37-abi3-win_amd64.whl (128.5 kB view hashes)

Uploaded CPython 3.7+ Windows x86-64

routrie-0.5.3-cp37-abi3-win32.whl (124.0 kB view hashes)

Uploaded CPython 3.7+ Windows x86

routrie-0.5.3-cp37-abi3-musllinux_1_2_x86_64.whl (388.5 kB view hashes)

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

routrie-0.5.3-cp37-abi3-musllinux_1_2_i686.whl (405.8 kB view hashes)

Uploaded CPython 3.7+ musllinux: musl 1.2+ i686

routrie-0.5.3-cp37-abi3-musllinux_1_2_armv7l.whl (529.8 kB view hashes)

Uploaded CPython 3.7+ musllinux: musl 1.2+ ARMv7l

routrie-0.5.3-cp37-abi3-musllinux_1_2_aarch64.whl (367.2 kB view hashes)

Uploaded CPython 3.7+ musllinux: musl 1.2+ ARM64

routrie-0.5.3-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl (247.2 kB view hashes)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ s390x

routrie-0.5.3-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (288.1 kB view hashes)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ ppc64le

routrie-0.5.3-cp37-abi3-manylinux_2_17_ppc64.manylinux2014_ppc64.whl (296.4 kB view hashes)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ ppc64

routrie-0.5.3-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (188.6 kB view hashes)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ ARMv7l

routrie-0.5.3-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (186.6 kB view hashes)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ ARM64

routrie-0.5.3-cp37-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.whl (199.4 kB view hashes)

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

routrie-0.5.3-cp37-abi3-manylinux_2_5_i686.manylinux1_i686.whl (220.0 kB view hashes)

Uploaded CPython 3.7+ manylinux: glibc 2.5+ i686

routrie-0.5.3-cp37-abi3-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (349.2 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.5.3-cp37-abi3-macosx_10_7_x86_64.whl (181.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