OxL Reference

method Router.dispatch

Route lookup and call, without the middleware.

Example:

oxl✓ checked in CI
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, time

Thread safety. reads the router only; safe to call from many tasks at once.

Since. 1.0.0-beta

Parameters

NameType
reqRequest

Returns

Reply

Effects

net, io, time

Defined in: std/http/http.oxl:3707

See also