Skip to content

Configuration

Customize the server with WebServiceConfigBuilder:

WebServer.start(MyApp::registerRoutes, new WebServiceConfigBuilder()
.setPort(8080)
.setDefaultBlockingTimeoutMillis(5000)
.setExceptionHandler(Throwable::printStackTrace)
.setMaxBodySize(1_048_576)
.build());
MethodDescriptionDefault
setPort(int)The port the server listens on8080
setDefaultBlockingTimeoutMillis(int)Timeout for blocking pipeline steps5000
setExceptionHandler(Consumer<Throwable>)Handler for uncaught exceptions
setMaxBodySize(int)Maximum request body size in bytes
setCorsConfig(CorsConfig)CORS policy configuration

Use CorsConfigBuilder to configure CORS:

new WebServiceConfigBuilder()
.setCorsConfig(new CorsConfigBuilder()
.allowOrigin("https://example.com")
.build())
.build();