Routing is simple and powerful in Lynx.
Basic
Parameters
Paths can contain named parameters that are extracted from the URL.
You can have multiple parameters in a path.
JSON
JSON can be retrieved from the request body.
Wildcards
Wildcards can be used to match multiple paths. When placed at the end of a path, it matches any path that starts with the prefix.
If you don’t need a named parameter, you can use a wildcard instead. It only matches one level.
Grouping
Routes can be grouped in sub-apps and then routed on the main app.
Middleware
Middleware can be used to modify the context before or after the handler is executed.
If you don’t specify, it’s applied to all routes. It can be applied to a specific path.
Middleware can also modify the response after the handler is executed.
Priority
Handlers and middleware are executed in the order they are defined.
Once the first handler is executed, no more handlers are executed for that request.
Middleware must be defined before the handler it applies to.