public sealed 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.Disables auto-configuring the current instance withJexPluginloaded using the ServiceLoader.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.Returns the configured JSON service.jsonService(JsonService jsonService) Sets the JSON service used for (de)serialization.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.intReturn the socket backlog.socketBacklog(int backlog) Set the socket backlog.booleanReturn true if SPI plugins should be loaded and registered.
-
Method Details
-
host
Set the host on which the HttpServer will bind to. Defaults to any local address.- Parameters:
host- The host.
-
port
Sets the port number on which the HttpServer will listen for incoming requests.- Parameters:
port- The port number.
-
contextPath
Set the contextPath.- Parameters:
contextPath- The context path which defaults to "/".
-
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
-
health
Enables/Disables the default health endpoint.- Parameters:
health- whether to enable/disable.
-
ignoreTrailingSlashes
Configures whether trailing slashes in request URIs should be ignored.- Parameters:
ignoreTrailingSlashes- whether to enable/disable trailing slashes.
-
jsonService
Sets the JSON service used for (de)serialization.- Parameters:
jsonService- The json service instance.
-
renderer
Registers a template renderer for a specific file extension.- Parameters:
extension- The file extension.renderer- The template renderer implementation.
-
executor
Sets the executor service used to handle incoming requests.- Parameters:
executor- The executor service.
-
httpsConfig
Enable https with the providedHttpsConfigurator- Parameters:
https- The HTTPS configuration.
-
compression
Configures compression settings using a consumer function.- Parameters:
consumer- The consumer function to configure compression settings.- Returns:
- The updated configuration.
-
port
int port()Returns the configured port number. (Defaults to 8080 if not set) -
host
String host()Returns the configured host. (Defaults to localhost if not set) -
contextPath
String contextPath()Return the contextPath. (Defaults to "/") -
health
boolean health()Returns whether the health endpoint is enabled. -
ignoreTrailingSlashes
boolean ignoreTrailingSlashes()Returns whether trailing slashes in request URIs are ignored. -
jsonService
JsonService jsonService()Returns the configured JSON service. -
httpsConfig
HttpsConfigurator httpsConfig()Return theHttpsConfiguratorif https is enabled. -
scheme
String scheme()Return the schema as http or https. -
compression
CompressionConfig compression()Returns the configured compression settings. -
renderers
Map<String,TemplateRender> renderers()Returns a map of registered template renderers, keyed by file extension. -
executor
Executor executor()Executor for serving requests. Defaults to ainvalid reference
Executors#newVirtualThreadPerTaskExecutor() -
disableSpiPlugins
JexConfig disableSpiPlugins()Disables auto-configuring the current instance withJexPluginloaded using the ServiceLoader. -
socketBacklog
int socketBacklog()Return the socket backlog. -
useSpiPlugins
boolean useSpiPlugins()Return true if SPI plugins should be loaded and registered.
-