← all packages

router

Lightweight path router with parameter extraction and middleware support. Pair with raw sockets when you don't need the full Wings stack.

Install

Latest (0.4.1)
tulpar pkg add router@0.4.1

Make sure your tulpar.toml has [registry] url = "https://pkg.tulparlang.dev", then run tulpar pkg install.

Details

Repository
https://github.com/hamer1818/tulpar-pkg-router
License
MIT
Author
Hamza ORTATEPE
Tags
httprouting

router is a minimal path-matcher you can embed in any Tulpar program. It does not run a server — it only matches an incoming request line + method to a registered handler and pulls the named parameters out for you. Bring your own socket loop.

Quick example

import "router";

router_register("GET", "/users/:id", "show_user");
router_register("POST", "/users", "create_user");

arrayJson match = router_match("GET", "/users/42");
print(match["handler"]);          // "show_user"
print(match["params"]["id"]);     // "42"

Use this when you want a thin layer on top of socket_* and full control over the request lifecycle. For a full HTTP framework, see wings.

Versions