OxyRoute uses the matchit 0.7 style of patterns (see upstream docs for the full pattern grammar). Typical path parameters use a : prefix, for example:
/items/:id/users/:user_id/posts/:post_id
The Python App class exposes:
get,post,put,patch,delete
Each is a decorator that registers a route and returns the handler unchanged (so you can stack multiple decorators on the same function only if you design for it—usually one method/path per handler is enough).
- The request path from RSGI is matched against the tree for the request method.
- If no route matches, the response is 404 with a plain
Not Foundbody (from the Rust dispatch layer). - Non-
httpRSGI scopes are ignored in the current implementation (no response is sent for unknownprotovalues).
- OxyRoute now auto-compiles the route snapshot on the first HTTP request, so hot-path
matching uses the lock-free compiled tables even if
freeze()was not called explicitly. - Calling
freeze()is still supported and remains the strict "no more route registration" switch. - If routes are added before
freeze(), OxyRoute invalidates the previous compiled snapshot and lazily rebuilds it on the next request.
If OpenAPI is enabled, route registration also updates a minimal OpenAPI document. See openapi.md.
For shared path prefixes (for example /api/v1/...), build routes on an APIRouter, then mount them on the main App with include_router(router, prefix=...). Optional keyword arguments to include_router are merged with each route’s own options; per-route options win on key conflicts (same as FastAPI’s include_router defaults).
oxyroute.APIRouter: the sameget/post/put/patch/delete/optionsdecorators asApp, but they only record routes.App.include_router(router, prefix=""): registers all recorded routes on the nativeAppwithjoin_path(prefix, route_path)(leading slashes normalized).- Nesting:
parent_router.include_router(child_router, prefix="…")flattens child routes with that prefix, then the parent is mounted onAppas usual. - Duplicate path + method: still rejected at register time (same as registering twice on
App).
Example: examples/routers_include_app.py
- Handlers — how matched parameters become keyword arguments
- Quick example in the repository