# http/router
Wrap a map as `%Router{}` and register it for `http/serve`.
## Syntax
[http/router $map]
## Parameters
- `$map` — router definition map
## Map keys
- `:routes` — vector of `%{ path method handler }` route maps
- `:statics` — vector of `%{ path dir }` (or `%{ url_path fs_path }`) static mounts
- `:prefix` — optional URL prefix applied to all routes and statics
- `:middleware` — vector of handler fns applied in order. Each runs as its
own coroutine, so `[await ...]` works inside middleware. Returning `false`
rejects the request; writing a response early short-circuits the chain.
## Examples
def app %{ prefix "/api" routes @{ %{ path "/" method :GET handler { "Hello" } } } statics @{ %{ path "/assets" dir "./public" } } } |> http/router [http/serve 8080 $app]
## Returns
`%Router{}` tagged map (the input wrapped).
## See Also
`http/serve`