HttpRoute

Up and coming: shot check knows this class and its members today, and programs run it once the native runtime lands.

ShotInstancenot creatablecomingWeb

Up and coming

Nest routes with :name parameters, and guard a whole branch of them at once.

HttpServer's Route(path) gives one, and its own Route nests another: "shop", then "items/:name". A request's Params hold the :name parts and Rest what is left of the path past the matched route. A Guard runs before every handler under its route, and a Response it returns answers instead.

Properties

NameTypeDefaultDescription
PathstringThe full path from the server's root.
Handler((request: Request) -> Response | string)?

Methods

NameArgumentsReturnsDescription
Route(path: string, handler: ((request: Request) -> Response | string)?)HttpRouteNests a route under this one; the :name parts of its path reach the handler in the request's Params.
Guard(check: (request: Request) -> Response?)()Runs the check before every handler under this route; a Response it returns answers instead.
From ShotInstance 33