All Projects → nitely → Kua

nitely / Kua

Licence: mit
⚡️ Lightning fast URL routing in Python (trie router)

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Kua

Muxie
Muxie is a modern, fast and light HTTP multiplexer for Go. Fully compatible with the http.Handler interface. Written for everyone.
Stars: ✭ 257 (+1327.78%)
Mutual labels:  trie, router
Router
⚡️ A lightning fast HTTP router
Stars: ✭ 158 (+777.78%)
Mutual labels:  trie, router
Pyahocorasick
Python module (C extension and plain python) implementing Aho-Corasick algorithm
Stars: ✭ 593 (+3194.44%)
Mutual labels:  trie
Find My Way
A crazy fast HTTP router
Stars: ✭ 776 (+4211.11%)
Mutual labels:  router
Androuter
A android router framework used to map url to activities or actions.
Stars: ✭ 730 (+3955.56%)
Mutual labels:  router
Navaid
A navigation aid (aka, router) for the browser in 850 bytes~!
Stars: ✭ 648 (+3500%)
Mutual labels:  router
Lion
Lion is a fast HTTP router for building modern scalable modular REST APIs in Go
Stars: ✭ 750 (+4066.67%)
Mutual labels:  router
Ciscoconfparse
Parse, Audit, Query, Build, and Modify Cisco IOS-style configurations. Python Infrastructure as Code (IaC) for Cisco IOS (and other vendors).
Stars: ✭ 562 (+3022.22%)
Mutual labels:  router
Macaw
🐦 Simple PHP router
Stars: ✭ 888 (+4833.33%)
Mutual labels:  router
Found
Extensible route-based routing for React applications
Stars: ✭ 718 (+3888.89%)
Mutual labels:  router
React Keeper
A routing library of React.
Stars: ✭ 774 (+4200%)
Mutual labels:  router
Flutter thrio
flutter_thrio makes it easy and fast to add flutter to existing mobile applications, and provide a simple and consistent navigator APIs.
Stars: ✭ 717 (+3883.33%)
Mutual labels:  router
Bitcask
🔑A high performance Key/Value store written in Go with a predictable read/write performance and high throughput. Uses a Bitcask on-disk layout (LSM+WAL) similar to Riak.
Stars: ✭ 654 (+3533.33%)
Mutual labels:  trie
Path To Regexp
Turn a path string such as `/user/:name` into a regular expression
Stars: ✭ 6,789 (+37616.67%)
Mutual labels:  router
Micro Router
🚉 A tiny and functional router for Zeit's Micro
Stars: ✭ 621 (+3350%)
Mutual labels:  router
One
一个极简高性能php框架,支持[swoole | php-fpm ]环境
Stars: ✭ 789 (+4283.33%)
Mutual labels:  router
Hat Trie
C++ implementation of a fast and memory efficient HAT-trie
Stars: ✭ 565 (+3038.89%)
Mutual labels:  trie
Nano Sql
Universal database layer for the client, server & mobile devices. It's like Lego for databases.
Stars: ✭ 717 (+3883.33%)
Mutual labels:  trie
Router
一款单品、组件化、插件化全支持的Andoid端路由框架。
Stars: ✭ 741 (+4016.67%)
Mutual labels:  router
Multiprocessrouter
一个多进程路由框架,使用APT处理路由接口的注册和初始化。多个模块间可以进行IPC调用。
Stars: ✭ 18 (+0%)
Mutual labels:  router

kua

Build Status Coverage Status pypi licence

Lightning fast URL routing in Python.

kua is a Trie-like based router. It scales better than regex based routers and due to this it's usually faster.

It's pretty bare bones and it's meant to be used in more feature-rich routers.

Compatibility

  • Python 3.5

Install

$ pip install kua

Usage

import kua

routes = kua.Routes()
routes.add('api/:foo', {'GET': my_get_controller})
route = routes.match('api/hello-world')
route.params
# {'foo': 'hello-world'}
route.anything
# {'GET': my_get_controller}

-> More

Docs

Read The Docs

Tests

$ make test

Backtracking

Backtracking means kua will have to try more than one path to match the URL.

This may hurt performance, depending how much backtracking is involved, usually you should not worry about it, though.

This reduces to not placing two variables next to each other and not placing a variable where there is a static one in a similar pattern.

Here are some examples of good and bad schemas:

# bad
routes.add(':var', ...)  # clashes with pretty much every pattern

# still bad
routes.add(':var1/:var2', ...)

# bad
routes.add(':var1/foo', ...)

# still bad
routes.add(':var1/:var2/foo', ...)

# bad
routes.add('api/:var1', ...)
routes.add('api/foo', ...)

# still bad
routes.add('api/:var1/:var2', ...)
routes.add('api/foo', ...)

# still bad
routes.add('api/:var1/foo', ...)
routes.add('api/foo', ...)

# good
routes.add('api', ...)
routes.add('api/:var', ...)
routes.add('api/:var/foo', ...)
routes.add('api/:var/bar', ...)
routes.add('api/:var/foo/:var2', ...)
routes.add('api/:var/bar/:var2', ...)

# good
routes.add('topics', ...)
routes.add('topics/:var', ...)
routes.add('authors', ...)
routes.add('authors/:var', ...)

# good
routes.add('shelf', ...)
routes.add('shelf/books', ...)
routes.add('shelf/books/:var', ...)

# good
routes.add('books/all', ...)
routes.add('books/removed', ...)
routes.add('books/pending', ...)

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].