Interface StaticContentConfig

All Superinterfaces:
Prototype.Api, Prototype.Factory<StaticContentFeature>
All Known Implementing Classes:
StaticContentConfig.BuilderBase.StaticContentConfigImpl

public interface StaticContentConfig extends Prototype.Api
Configuration of Static content feature.

Minimal example configuring a single classpath resource (properties):

server.features.static-content.classpath.0.context=/static
server.features.static-content.classpath.0.location=/web
and using yaml:
server:
  features:
    static-content:
      classpath:
        - context: "/static"
          location: "/web"
See Also:
  • Method Details

    • builder

      static StaticContentConfig.Builder builder()
      Create a new fluent API builder to customize configuration.
      Returns:
      a new builder
    • builder

      Create a new fluent API builder from an existing instance.
      Parameters:
      instance - an existing instance used as a base for the builder
      Returns:
      a builder based on an instance
    • create

      static StaticContentConfig create(Config config)
      Create a new instance from configuration.
      Parameters:
      config - used to configure the new instance
      Returns:
      a new instance configured from configuration
    • create

      static StaticContentConfig create()
      Create a new instance with default values.
      Returns:
      a new instance
    • enabled

      boolean enabled()
      Whether this feature is enabled, defaults to true.
      Returns:
      whether this feature is enabled
    • weight

      double weight()
      Weight of the static content feature. Defaults to 95.0.
      Returns:
      weight of the feature
    • name

      String name()
      Name of this instance.
      Returns:
      instance name
    • memoryCache

      Optional<MemoryCache> memoryCache()
      Memory cache shared by the whole feature. If not configured, files are not cached in memory (except for explicitly marked files/resources in each section).
      Returns:
      memory cache, if configured
    • temporaryStorage

      Optional<TemporaryStorage> temporaryStorage()
      Temporary storage to use across all classpath handlers. If not defined, a default one will be created.
      Returns:
      temporary storage
    • classpath

      List of classpath based static content handlers.
      Returns:
      classpath handlers
    • path

      List of file system based static content handlers.
      Returns:
      path handlers
    • contentTypes

      Map<String, MediaType> contentTypes()
      Maps a filename extension to the response content type. To have a system-wide configuration, you can use the service loader SPI MediaTypeDetector.

      This method can override MediaTypes detection for a specific static content handler.

      Handler will use a union of configuration defined here, and on the handler here when used from configuration.

      Returns:
      map of file extensions to associated media type
    • welcome

      Optional<String> welcome()
      Welcome-file name. Default for all handlers. By default, we do not serve default files.
      Returns:
      welcome-file name, such as index.html
    • sockets

      Set<String> sockets()
      Sockets names (listeners) that will host static content handlers, defaults to all configured sockets. Default socket name is @default.

      This configures defaults for all handlers.

      Returns:
      sockets to register this handler on
    • preCompressedEnabled

      boolean preCompressedEnabled()
      Whether pre-compressed sidecar resources should be selected by default for feature-registered directory and classpath handlers; this is disabled by default and does not apply to file system handlers configured with a single file, which require handler-level opt-in.
      Returns:
      whether pre-compressed sidecar resources should be used
    • preCompressedCrossOriginSourcingEnabled

      boolean preCompressedCrossOriginSourcingEnabled()
      Whether classpath sidecar resources may be sourced from a different classpath origin than the logical resource by default for feature-registered handlers.
      Returns:
      whether cross-origin classpath sidecar sourcing is enabled by default
    • preCompressedEncodings

      Map<String,String> preCompressedEncodings()
      Pre-compressed content coding to file suffix mappings; defaults include br to br and gzip to gz, handler-level mappings replace these mappings rather than merging with them, an explicit empty map disables sidecar lookups by default, codings must be unique concrete valid HTTP tokens other than identity and *, and suffixes have leading dots ignored and must not contain path separators.
      Returns:
      content coding to file suffix mappings