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.
Summary
Properties
Section titled “Properties”handler
Section titled “handler” HttpServer.handler :: Handler?
The test's handler, which answers every request before the default routes.
gatewayUrl
Section titled “gatewayUrl” HttpServer.gatewayUrl :: function
Returns the websocket URL, or nil when no websocket server exists.
onStop
Section titled “onStop” HttpServer.onStop :: function?
Called with the handle after it stops.
server
Section titled “server” HttpServer.server :: any?
The Zune server handle, nil after it stops.
The ephemeral port the server bound to.
The server's base URL, http://127.0.0.1:{port}.
Methods
Section titled “Methods”respond
Section titled “respond”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.
Functions
Section titled “Functions”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 |