Skip to content

HttpServer

A localhost HTTP server with the /gateway/bot default. new starts it on an ephemeral port and stores the handler; the handler may answer any route by returning a response or a raw string body, and falls through to the default by returning nil.

HttpServer.handler  :: Handler?

The test's handler, which answers every request before the default routes.

HttpServer.gatewayUrl  :: function

Returns the websocket URL, or nil when no websocket server exists.

HttpServer.onStop  :: function?

Called with the handle after it stops.

HttpServer.server  :: any?

The Zune server handle, nil after it stops.

HttpServer.port  :: number

The ephemeral port the server bound to.

HttpServer.url  :: string

The server's base URL, http://127.0.0.1:{port}.

HttpServer : respond ( request )  -> string | ZuneResponse

Answers one request: the handler first, then the default.

Parameters

request: ZuneRequest

Returns

string | ZuneResponse
HttpServer : stop ( )  -> ()

Stops listening. Safe to call twice.

HttpServer . new ( settings )  -> HttpServer

Creates and starts the server on 127.0.0.1 with an ephemeral port.

Parameters

settings: {
handler: Handler?,
gatewayUrl: () -> string?,
onStop: ((server,
}

Returns

HttpServer