OxL Справочник OxL
РусскийEnglish

method Router.dispatch

Route lookup and call, without the middleware.

Example:

oxl✓ проверяется в 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}")
}
Вывод
405
pub(api) fn dispatch(req: Request) -> Reply  net, io, time

Потокобезопасность. reads the router only; safe to call from many tasks at once.

С версии. 1.0.0-beta

Параметры

ИмяТип
reqRequest

Возвращает

Reply

Эффекты

net, io, time

Определено в: std/http/http.oxl:3707

См. также