Module io.avaje.jex
Package io.avaje.jex

Interface JexConfig


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 Details

    • compression

      CompressionConfig compression()
      Returns the configured compression settings.
    • compression

      JexConfig compression(Consumer<CompressionConfig> consumer)
      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

      JexConfig contextPath(String 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 a Executors.newVirtualThreadPerTaskExecutor()
    • executor

      JexConfig executor(Executor 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

      JexConfig health(boolean health)
      Enables/Disables the default health endpoint.
      Parameters:
      health - whether to enable/disable.
    • host

      String host()
      Returns the configured host.
    • host

      JexConfig host(String host)
      Set the host on which the HttpServer will bind to. Defaults to any local address.
      Parameters:
      host - The host.
    • httpsConfig

      HttpsConfigurator httpsConfig()
      Return the HttpsConfigurator if https is enabled.
    • httpsConfig

      JexConfig httpsConfig(HttpsConfigurator https)
      Enable https with the provided HttpsConfigurator
      Parameters:
      https - The HTTPS configuration.
    • ignoreTrailingSlashes

      boolean ignoreTrailingSlashes()
      Returns whether trailing slashes in request URIs are ignored.
    • ignoreTrailingSlashes

      JexConfig ignoreTrailingSlashes(boolean 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

      JexConfig initialStreamBufferSize(int initialSize)
      Set the initial size of the response stream buffer. If exceeded, the buffer will expand until it reaches the maximum configured size

      Defaults to 256

      Parameters:
      initialSize - The initial size of the response buffer
    • jsonService

      JsonService jsonService()
      Returns the configured JSON service.
    • jsonService

      JexConfig jsonService(JsonService 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

      JexConfig maxStreamBufferSize(long maxSize)
      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

      JexConfig port(int 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.
    • rangeChunkSize

      int rangeChunkSize()
      The configured rangeChunk size
    • rangeChunkSize

      JexConfig rangeChunkSize(int rangeChunkSize)
      Set the chunk size on range requests, set to a high number to reduce the amount of range requests (especially for video streaming)
      Parameters:
      rangeChunkSize - chunk size on range requests
    • renderer

      JexConfig renderer(String extension, TemplateRender 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 the HttpServer instance. If not set, HttpServerProvider.provider() will be used to create the server
    • serverProvider

      JexConfig serverProvider(HttpServerProvider serverProvider)
      Configure Provider used to created HttpServer instances. 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

      JexConfig socketBacklog(int backlog)
      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