Interface StaticContent.Builder

Enclosing interface:
StaticContent

public static sealed interface StaticContent.Builder
Builder for StaticContent.
  • Method Details

    • httpPath

      StaticContent.Builder httpPath(String path)
      Sets the HTTP path for the static resource handler.
      Parameters:
      path - the HTTP path prefix
      Returns:
      the updated configuration
    • directoryIndex

      StaticContent.Builder directoryIndex(String directoryIndex)
      Sets the index file to be served when a directory is requests.
      Parameters:
      directoryIndex - the index file
      Returns:
      the updated configuration
    • preCompress

      StaticContent.Builder preCompress()
      Sent resources will be pre-compressed and cached in memory when this is enabled
      Returns:
      the updated configuration
    • resourceLoader

      StaticContent.Builder resourceLoader(ClassResourceLoader resourceLoader)
      Sets a custom resource loader for loading class/module path resources. This is normally used when running the application on the module path when files cannot be discovered.

      Example usage: service.resourceLoader(ClassResourceLoader.create(getClass()))

      Parameters:
      resourceLoader - the custom resource loader
      Returns:
      the updated configuration
    • putMimeTypeMapping

      StaticContent.Builder putMimeTypeMapping(String ext, String mimeType)
      Adds a new MIME type mapping to the configuration. (Default: uses URLConnection.getFileNameMap()
      Parameters:
      ext - the file extension (e.g., "html", "css", "js")
      mimeType - the corresponding MIME type (e.g., "text/html", "text/css", "application/javascript")
      Returns:
      the updated configuration
    • putResponseHeader

      StaticContent.Builder putResponseHeader(String key, String value)
      Adds a new response header to the configuration.
      Parameters:
      key - the header name
      value - the header value
      Returns:
      the updated configuration
    • skipFilePredicate

      StaticContent.Builder skipFilePredicate(Predicate<Context> skipFilePredicate)
      Sets a predicate to filter files based on the request context.
      Parameters:
      skipFilePredicate - the predicate to use
      Returns:
      the updated configuration
    • build

      StaticContent build()
      Build and return the StaticContent.