HttpServer

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

Let other programs on this computer send your running program requests.

HttpService:ServeAsync(options) gives one, a child of HttpService, listening on this computer only, at the first free port from the one asked for. Route answers a method and a path; with a path alone it gives an HttpRoute. Requests and responses work as in PageService, which serves your program's own pages.

Properties

NameTypeDefaultDescription
Urlstring
PortnumberThe port it listens on: the first free one from the Port that ServeAsync asked for.

Methods

NameArgumentsReturnsDescription
Route(method: string, path: string, handler: (request: Request) -> Response | string)()Answers requests for a method and path with the handler; with a path alone it gives an HttpRoute to nest routes under.
Route(path: string, handler: ((request: Request) -> Response | string)?)HttpRouteAnswers requests for a method and path with the handler; with a path alone it gives an HttpRoute to nest routes under.
Stop()()

Events

NamePassesDescription
RequestReceived(Request)Fires with every request, after it was answered.
From ShotInstance 33