Module io.avaje.jex.staticcontent
Package io.avaje.jex.staticcontent
Interface StaticContent.Builder
- Enclosing interface:
StaticContent
public static sealed interface StaticContent.Builder
Builder for StaticContent.
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Build and return the StaticContent.directoryIndex(String directoryIndex) Sets the index file to be served when a directory is requests.Sets the HTTP path for the static resource handler.Sent resources will be pre-compressed and cached in memory when this is enabledputMimeTypeMapping(String ext, String mimeType) Adds a new MIME type mapping to the configuration.putResponseHeader(String key, String value) Adds a new response header to the configuration.resourceLoader(ClassResourceLoader resourceLoader) Sets a custom resource loader for loading class/module path resources.skipFilePredicate(Predicate<Context> skipFilePredicate) Sets a predicate to filter files based on the request context.
-
Method Details
-
httpPath
Sets the HTTP path for the static resource handler.- Parameters:
path- the HTTP path prefix- Returns:
- the updated configuration
-
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
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
Adds a new MIME type mapping to the configuration. (Default: usesURLConnection.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
Adds a new response header to the configuration.- Parameters:
key- the header namevalue- the header value- Returns:
- the updated configuration
-
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.
-