An HTTP and WebSockets server.
You receive HTTP requests by providing a requestHandler. As requests arrive on the server the handler will be called with the requests.
You receive WebSockets by providing a websocketHandler. As WebSocket connections arrive on the server, the WebSocket is passed to the handler.
Anything
HttpServer
Basic
Identifiable
Object
Anything
no subtypes hierarchy
Initializer |
HttpServer(HttpServer unknown) |
Inherited Attributes |
Attributes inherited from: Object hash , string |
Methods | |
actualPort | shared default Integer actualPort() The actual port the server is listening on. This is useful if you bound the server specifying 0 as port number signifying an ephemeral port |
close | shared default void close() Close the server. Any open HTTP connections will be closed. The close happens asynchronously and the server may not be closed until some time after the call has returned. |
close | shared default void close(Anything(Throwable?) completionHandler) Like close but supplying a handler that will be called when the server is actually closed (or has failed). Parameters:
|
connectionHandler | shared default HttpServer connectionHandler(Anything(HttpConnection) handler) Set a connection handler for the server. |
exceptionHandler | shared default HttpServer exceptionHandler(Anything(Throwable) handler) Set an exception handler called for socket errors happening before the HTTP connection is established, e.g during the TLS handshake. Parameters:
|
isMetricsEnabled | shared actual default Boolean isMetricsEnabled() Whether the metrics are enabled for this measured object Refines Measured.isMetricsEnabled |
listen | shared default HttpServer listen() Tell the server to start listening. The server will listen on the port and host specified in the HttpServerOptions that was used when creating the server. The listen happens asynchronously and the server may not be listening until some time after the call has returned. |
listen | shared default HttpServer listen(Anything(Throwable|HttpServer) listenHandler) Like listen but supplying a handler that will be called when the server is actually listening (or has failed). Parameters:
|
listen | shared default HttpServer listen(Integer port) Like listen but the server will listen on host “0.0.0.0” and port specified here ignoring any value in the HttpServerOptions that was used when creating the server. Parameters:
|
listen | shared default HttpServer listen(Integer port, Anything(Throwable|HttpServer) listenHandler) Like listen but supplying a handler that will be called when the server is actually listening (or has failed). Parameters:
|
listen | shared default HttpServer listen(Integer port, String host) Tell the server to start listening. The server will listen on the port and host specified here, ignoring any value set in the HttpServerOptions that was used when creating the server. The listen happens asynchronously and the server may not be listening until some time after the call has returned. Parameters:
|
listen | shared default HttpServer listen(Integer port, String host, Anything(Throwable|HttpServer) listenHandler) Like listen but supplying a handler that will be called when the server is actually listening (or has failed). Parameters:
|
requestHandler | shared default HttpServer requestHandler(Anything(HttpServerRequest) handler) Set the request handler for the server to |
requestStream | shared default ReadStream<HttpServerRequest> requestStream() Return the request stream for the server. As HTTP requests are received by the server, instances of HttpServerRequest will be created and passed to the stream . |
websocketHandler | shared default HttpServer websocketHandler(Anything(ServerWebSocket) handler) Set the websocket handler for the server to |
websocketStream | shared default ReadStream<ServerWebSocket> websocketStream() Return the websocket stream for the server. If a websocket connect handshake is successful a new ServerWebSocket instance will be created and passed to the stream . |
Inherited Methods |
Methods inherited from: Object equals |
Methods inherited from: Measured |