larzrouter
URL routing like a web framework.
Routing is the heart of every web framework: taking an incoming URL and deciding which function handles it, pulling out the parts (like an id) along the way. larzrouter does exactly that in code you can read - path params, matching, and building URLs back.
larzscript pkg install router
What you get
- Routes with <name> and <int:id> params
- match() -> handler + params
- add() - no decorators needed
- build() URLs from templates
Try it
import "router" as router
let r = router.new()
router.add(r, "/users/<int:id>", "get_user")
router.add(r, "/users/<name>/posts", "user_posts")
let m = router.match(r, "/users/42")
print(m["handler"], m["params"])
print(router.build("/users/<int:id>", {"id": 42}))Output
get_user {id: 42}
/users/42Why it's in the Larz Stack
larzrouter is a real Larzscript package (larzscript pkg install router) - money-native, zero dependencies, the same language as the rest of the estate, not a separate Python runtime. It composes with the rest of the Larz Stack and the Larz framework.