public interface JexConfig
Jex configuration interface.
Provides a fluent API for configuring Jex's various settings, including port, host, health endpoint, trailing slash handling, JSON service, template renderers, executor service, HTTPS configuration, compression, and plugin loading.
-
Method Summary
Modifier and TypeMethodDescriptionReturns the configured compression settings.compression(Consumer<CompressionConfig> consumer) Configures compression settings using a consumer function.Return the contextPath.contextPath(String contextPath) Set the contextPath passed to the underlying HttpServer.executor()Executor for serving requests.Sets the executor service used to handle incoming requests.booleanhealth()Returns whether the health endpoint is enabled.health(boolean health) Enables/Disables the default health endpoint.host()Returns the configured host.Set the host on which the HttpServer will bind to.Return theHttpsConfiguratorif https is enabled.httpsConfig(HttpsConfigurator https) Enable https with the providedHttpsConfiguratorbooleanReturns whether trailing slashes in request URIs are ignored.ignoreTrailingSlashes(boolean ignoreTrailingSlashes) Configures whether trailing slashes in request URIs should be ignored.intThe initial size of the response bufferinitialStreamBufferSize(int initialSize) Set the initial size of the response stream buffer.Returns the configured JSON service.jsonService(JsonService jsonService) Sets the JSON service used for (de)serialization.longthe maximum size of the response stream buffer.maxStreamBufferSize(long maxSize) Set the maximum size of the response stream buffer.intport()Returns the configured port number.port(int port) Sets the port number on which the HttpServer will listen for incoming requests. *renderer(String extension, TemplateRender renderer) Registers a template renderer for a specific file extension.Returns a map of registered template renderers, keyed by file extension.scheme()Return the schema as http or https.Provide the provider used to create theHttpServerinstance.serverProvider(HttpServerProvider serverProvider) Configure Provider used to createdHttpServerinstances.intReturn the socket backlog.socketBacklog(int backlog) Set the socket backlog.
-
Method Details
-
compression
CompressionConfig compression()Returns the configured compression settings. -
compression
Configures compression settings using a consumer function.- Parameters:
consumer- The consumer function to configure compression settings.- Returns:
- The updated configuration.
-
contextPath
String contextPath()Return the contextPath. (Defaults to "/") -
contextPath
Set the contextPath passed to the underlying HttpServer. (defaults to "/")- Parameters:
contextPath- The context path
-
executor
Executor executor()Executor for serving requests. Defaults to aExecutors.newVirtualThreadPerTaskExecutor() -
executor
Sets the executor service used to handle incoming requests.- Parameters:
executor- The executor service.
-
health
boolean health()Returns whether the health endpoint is enabled. -
health
Enables/Disables the default health endpoint.- Parameters:
health- whether to enable/disable.
-
host
String host()Returns the configured host. -
host
Set the host on which the HttpServer will bind to. Defaults to any local address.- Parameters:
host- The host.
-
httpsConfig
HttpsConfigurator httpsConfig()Return theHttpsConfiguratorif https is enabled. -
httpsConfig
Enable https with the providedHttpsConfigurator- Parameters:
https- The HTTPS configuration.
-
ignoreTrailingSlashes
boolean ignoreTrailingSlashes()Returns whether trailing slashes in request URIs are ignored. -
ignoreTrailingSlashes
Configures whether trailing slashes in request URIs should be ignored.- Parameters:
ignoreTrailingSlashes- whether to enable/disable trailing slashes.
-
initialStreamBufferSize
int initialStreamBufferSize()The initial size of the response buffer -
initialStreamBufferSize
Set the initial size of the response stream buffer. If exceeded, the buffer will expand until it reaches the maximum configured sizeDefaults to 256
- Parameters:
initialSize- The initial size of the response buffer
-
jsonService
JsonService jsonService()Returns the configured JSON service. -
jsonService
Sets the JSON service used for (de)serialization.- Parameters:
jsonService- The json service instance.
-
maxStreamBufferSize
long maxStreamBufferSize()the maximum size of the response stream buffer. -
maxStreamBufferSize
Set the maximum size of the response stream buffer. If the response data exceeds this size, it will be written to the client using chunked transfer encoding. Otherwise, the response will be sent using a Content-Length header with the exact size of the response data.Defaults to 4096
- Parameters:
maxSize- The maximum size of the response
-
port
int port()Returns the configured port number. (Defaults to 8080 if not set) -
port
Sets the port number on which the HttpServer will listen for incoming requests. *The default value is 8080. If The port is set to 0, the server will randomly choose an available port.
- Parameters:
port- The port number.
-
renderer
Registers a template renderer for a specific file extension.- Parameters:
extension- The file extension.renderer- The template renderer implementation.
-
renderers
Map<String,TemplateRender> renderers()Returns a map of registered template renderers, keyed by file extension. -
scheme
String scheme()Return the schema as http or https. -
serverProvider
HttpServerProvider serverProvider()Provide the provider used to create theHttpServerinstance. If not set,HttpServerProvider.provider()will be used to create the server -
serverProvider
Configure Provider used to createdHttpServerinstances. If not set,HttpServerProvider.provider()will be used to create the server.- Parameters:
serverProvider- provider used to create the server
-
socketBacklog
int socketBacklog()Return the socket backlog. -
socketBacklog
Set the socket backlog. If this value is less than or equal to zero, then a system default value is used- Parameters:
backlog- the socket backlog. If this value is less than or equal to zero, then a system default value is used
-