-
- All Implemented Interfaces:
public final class ServerServer that listen to HTTP connections on a port and address and route requests using a router.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classServer.Companion
-
Field Summary
Fields Modifier and Type Field Description private final RoutercontextRouterprivate final IntegerruntimePortprivate final StringportNameprivate final ServerSettingssettings
-
Constructor Summary
Constructors Constructor Description Server(ServerPort adapter, ServerSettings settings, Function1<Router, Unit> block)Create a server with a router. Server(ServerPort adapter, Router router, ServerSettings settings)
-
Method Summary
Modifier and Type Method Description final RoutergetContextRouter()Provide a Router instance configured with the context path in ServerSettings. final IntegergetRuntimePort()final StringgetPortName()The port name of the server. final ServerSettingsgetSettings()final Booleanstarted()Check whether the server has been started. final Unitstart()Start the server with the adapter instance and adds a shutdown hook for stopping the server. final Unitstop()Stop the server. -
-
Constructor Detail
-
Server
Server(ServerPort adapter, ServerSettings settings, Function1<Router, Unit> block)
Create a server with a router.- Parameters:
adapter- The server engine.settings- Server settings.block- Router's setup block.
-
Server
Server(ServerPort adapter, Router router, ServerSettings settings)
-
-
Method Detail
-
getContextRouter
final Router getContextRouter()
Provide a Router instance configured with the context path in ServerSettings.
-
getRuntimePort
final Integer getRuntimePort()
-
getPortName
final String getPortName()
The port name of the server.
-
getSettings
final ServerSettings getSettings()
-
start
final Unit start()
Start the server with the adapter instance and adds a shutdown hook for stopping the server.
-
-
-
-