Package io.karatelabs.http
Class HttpServer
java.lang.Object
io.karatelabs.http.HttpServer
- All Implemented Interfaces:
io.karatelabs.common.Stoppable,AutoCloseable
-
Method Summary
Modifier and TypeMethodDescriptionThe socket address the server actually bound to — a wildcard (isAnyLocalAddress) when started with a null/blank/"0.0.0.0"host, else the specific interface (e.g. loopback for"localhost").intgetPort()booleanisSsl()static voidstatic HttpServerstart(int port, io.netty.handler.ssl.SslContext sslContext, Function<HttpRequest, HttpResponse> handler) static HttpServerstart(int port, io.netty.handler.ssl.SslContext sslContext, Function<HttpRequest, HttpResponse> handler, SseHandler sseHandler) static HttpServerstart(int port, io.netty.handler.ssl.SslContext sslContext, Function<HttpRequest, HttpResponse> handler, SseHandler sseHandler, WsHandler wsHandler) static HttpServerstart(int port, Function<HttpRequest, HttpResponse> handler) static HttpServerstart(int port, Function<HttpRequest, HttpResponse> handler, SseHandler sseHandler) static HttpServerstart(int port, Function<HttpRequest, HttpResponse> handler, SseHandler sseHandler, WsHandler wsHandler) static HttpServerstart(String host, int port, Function<HttpRequest, HttpResponse> handler, SseHandler sseHandler, WsHandler wsHandler) Start bound to a specific interface —host="localhost"/"127.0.0.1"listens on loopback only (not reachable off-box),"0.0.0.0"/null/blank listens on every interface (the historical default).voidstop()Graceful, blocking, idempotent —stopAndWait()by another name, forKarateLifecycle.voidvoidvoidwaitSync()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.karatelabs.common.Stoppable
close, lifecycleExecutor
-
Method Details
-
shutdownAll
public static void shutdownAll() -
start
-
start
public static HttpServer start(int port, Function<HttpRequest, HttpResponse> handler, SseHandler sseHandler) -
start
public static HttpServer start(int port, io.netty.handler.ssl.SslContext sslContext, Function<HttpRequest, HttpResponse> handler) -
start
public static HttpServer start(int port, io.netty.handler.ssl.SslContext sslContext, Function<HttpRequest, HttpResponse> handler, SseHandler sseHandler) -
start
public static HttpServer start(int port, Function<HttpRequest, HttpResponse> handler, SseHandler sseHandler, WsHandler wsHandler) -
start
public static HttpServer start(int port, io.netty.handler.ssl.SslContext sslContext, Function<HttpRequest, HttpResponse> handler, SseHandler sseHandler, WsHandler wsHandler) -
start
public static HttpServer start(String host, int port, Function<HttpRequest, HttpResponse> handler, SseHandler sseHandler, WsHandler wsHandler) Start bound to a specific interface —host="localhost"/"127.0.0.1"listens on loopback only (not reachable off-box),"0.0.0.0"/null/blank listens on every interface (the historical default). Lets a server be hardened to localhost-only; the caller (e.g. karate-maxserve) decides the default per deployment (host-dev = localhost, in-container = 0.0.0.0 so Docker-pforwarding can reach it). -
isSsl
public boolean isSsl() -
getPort
public int getPort() -
getLocalAddress
The socket address the server actually bound to — a wildcard (isAnyLocalAddress) when started with a null/blank/"0.0.0.0"host, else the specific interface (e.g. loopback for"localhost"). For diagnostics + tests of the bind-host hardening. -
waitSync
public void waitSync() -
lifecycleName
- Specified by:
lifecycleNamein interfaceio.karatelabs.common.Stoppable
-
lifecycleKind
- Specified by:
lifecycleKindin interfaceio.karatelabs.common.Stoppable
-
stop
public void stop()Graceful, blocking, idempotent —stopAndWait()by another name, forKarateLifecycle. Servers that wrap one of these (mock server, OAuth2 callback server) inherit registration from here and must not register themselves as well.- Specified by:
stopin interfaceio.karatelabs.common.Stoppable
-
stopAndWait
public void stopAndWait() -
stopAsync
public void stopAsync()
-