Class StaticFiles.Builder

java.lang.Object
com.soklet.StaticFiles.Builder
Enclosing class:
StaticFiles

@NotThreadSafe public static final class StaticFiles.Builder extends Object
Builder for StaticFiles instances.
Author:
Mark Allen
  • Method Details

    • indexFileNames

      Sets the index file names to try when a request path resolves to a directory.

      Names are tried in list order. Each name must be a single file name, not a path; blank names, ., .., path separators, control characters, Windows drive paths, and UNC-style paths are rejected when the builder is built.

      Parameters:
      indexFileNames - the index file names, or null for no index files
      Returns:
      this builder
    • mimeTypeResolver

      Sets the resolver used to produce Content-Type values.

      The configured resolver fully replaces the default resolver. Soklet's default resolver uses a curated deterministic set of common web-asset extensions, returns Optional.empty() for unknown extensions, and does not call Files.probeContentType(Path). Applications that need OS-level MIME database behavior can configure a resolver that calls Files.probeContentType(...) directly.

      Parameters:
      mimeTypeResolver - the resolver to use, or null to restore the default resolver
      Returns:
      this builder
    • entityTagResolver

      Sets the resolver used to produce ETag values.

      Passing null restores the default weak metadata-based resolver.

      Parameters:
      entityTagResolver - the resolver to use, or null to restore the default resolver
      Returns:
      this builder
    • accessResolver

      Sets the resolver used to decide whether resolved files are served, denied, or hidden.

      The access resolver runs after path safety, index-file resolution, symlink policy, readability, regular-file checks, and attribute reads, but before MIME, validator, cache-control, extra-header, and range-request resolvers. It receives the resolved file path, not the original request path.

      Parameters:
      accessResolver - the resolver to use, or null to restore the allow-all default
      Returns:
      this builder
    • lastModifiedResolver

      Sets the resolver used to produce Last-Modified values.

      Passing null restores the default resolver, which uses the file attributes read for the response.

      Parameters:
      lastModifiedResolver - the resolver to use, or null to restore the default resolver
      Returns:
      this builder
    • cacheControlResolver

      Sets the resolver used to produce Cache-Control values.

      Passing null restores the disabled resolver, which omits Cache-Control.

      Parameters:
      cacheControlResolver - the resolver to use, or null to omit Cache-Control
      Returns:
      this builder
    • headersResolver

      Sets the resolver used to produce extra response headers.

      Passing null restores the disabled resolver, which emits no extra headers.

      Parameters:
      headersResolver - the resolver to use, or null to omit extra headers
      Returns:
      this builder
    • rangeRequestsResolver

      Sets the resolver used to decide whether byte range requests are honored.

      Passing null restores the default resolver, which enables range requests.

      Parameters:
      rangeRequestsResolver - the resolver to use, or null to enable range requests
      Returns:
      this builder
    • followSymlinks

      Sets whether symbolic links are followed while resolving static-file paths.

      Passing null restores the default of false. When disabled, any symbolic-link component under the static root causes the candidate path to be hidden.

      Parameters:
      followSymlinks - true to follow symlinks, false to reject them, or null for the default
      Returns:
      this builder
    • build

      Builds the static-file helper.

      The configured root is resolved to a real path and validated as a directory when this method is called.

      Returns:
      the configured static-file helper