method Router.dispatch
Route lookup and call, without the middleware.
Example:
use std.http { Router, Request, Reply }
fn main() io, net, time {
let router = Router.new().get("/a", (req: Request) => Reply.text("a"))
let req = Request{ method: "POST", target: "/a", path: "/a", rawQuery: "", version: "HTTP/1.1", headers: [], body: Utf8.encode(""), peer: "", params: [] }
let rep = router.dispatch(req)
print("{rep.status}")
}Output
405
pub(api) fn dispatch(req: Request) -> Reply net, io, timeThread safety. reads the router only; safe to call from many tasks at once.
Since. 1.0.0-beta
Parameters
| Name | Type |
|---|---|
req | Request |
Returns
Effects
net, io, time
Defined in: std/http/http.oxl:3707