Interface FileSystemHandlerConfig
- All Superinterfaces:
BaseHandlerConfig
,Prototype.Api
- All Known Implementing Classes:
FileSystemHandlerConfig.BuilderBase.FileSystemHandlerConfigImpl
File system based static content handler configuration.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic class
Fluent API builder forFileSystemHandlerConfig
.static class
FileSystemHandlerConfig.BuilderBase<BUILDER extends FileSystemHandlerConfig.BuilderBase<BUILDER,
PROTOTYPE>, PROTOTYPE extends FileSystemHandlerConfig> Fluent API builder base forFileSystemHandlerConfig
. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()
Create a new fluent API builder to customize configuration.builder
(FileSystemHandlerConfig instance) Create a new fluent API builder from an existing instance.A set of files that are cached in memory at startup.Maps a filename extension to the response content type.context()
Context that will serve this handler's static resources, defaults to/
.static FileSystemHandlerConfig
create()
Create a new instance with default values.static FileSystemHandlerConfig
Create a new instance from configuration.static FileSystemHandlerConfig
Create a new file system based static content configuration from the defined location.boolean
enabled()
Whether this handle is enabled, defaults totrue
.location()
The directory (or a single file) that contains the root of the static content.Handles will use memory cache configured onStaticContentConfigBlueprint.memoryCache()
by default.Map request path to resource path.Configure capacity of cache used for resources.sockets()
Sockets names (listeners) that will host this static content handler, defaults to all configured sockets.welcome()
Welcome-file name.
-
Method Details
-
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
Create a new instance from configuration.- Parameters:
config
- used to configure the new instance- Returns:
- a new instance configured from configuration
-
create
Create a new instance with default values.- Returns:
- a new instance
-
create
Create a new file system based static content configuration from the defined location. All other configuration is default.- Parameters:
location
- path on file system that is the root of static content (all files under it will be available!)- Returns:
- a new configuration for classpath static content handler
-
location
Path location()The directory (or a single file) that contains the root of the static content.- Returns:
- location to serve the static content, such as
"/home/user/static-content"
.
-
enabled
boolean enabled()Whether this handle is enabled, defaults totrue
.- Returns:
- whether enabled
-
context
String context()Context that will serve this handler's static resources, defaults to/
.- Returns:
- context under webserver
-
sockets
Sockets names (listeners) that will host this static content handler, defaults to all configured sockets. Default socket name is@default
.- Returns:
- sockets to register this handler on
-
welcome
Welcome-file name. In case a directory is requested, this file would be served if present. There is no welcome file by default.- Returns:
- welcome-file name, such as
index.html
-
cachedFiles
A set of files that are cached in memory at startup. These files are never removed from the in-memory cache, though their overall size is added to the memory cache used bytes. When using classpath, the set must contain explicit list of all files that should be cached, when using file system, it can contain a directory, and all files under that directory (recursive) would be cached as well.Note that files cached through this method may use more than the max-bytes configured for the in-memory cache (i.e. this option wins over the maximal size in bytes), so kindly be careful with what is pushed to the cache.
Files cached in memory will never be re-loaded, even if changed, until server restart!
- Returns:
- set of file names (or directory names if not using classpath) to cache in memory on startup
-
memoryCache
Optional<MemoryCache> memoryCache()Handles will use memory cache configured onStaticContentConfigBlueprint.memoryCache()
by default. In case a memory cache is configured here, it will replace the memory cache used by the static content feature, and this handle will use a dedicated memory cache instead.To disable memory caching for a single handler, create the configuration, and set
enabled: false
.- Returns:
- memory cache to use with this handler
-
contentTypes
Maps a filename extension to the response content type. To have a system-wide configuration, you can use the service loader SPIMediaTypeDetector
.This method can override
MediaTypes
detection for a specific static content handler.Handler will use a union of configuration on the
StaticContentConfig
and here when used from configuration.- Returns:
- map of file extensions to associated media type
-
pathMapper
Map request path to resource path. Default uses the same path as requested. This can be used to resolve all paths to a single file, or to filter out files.- Returns:
- function to map request path to resource path
-
recordCacheCapacity
Configure capacity of cache used for resources. This cache will make sure the media type and location is discovered faster.To cache content (bytes) in memory, use
BaseHandlerConfigBlueprint.memoryCache()
- Returns:
- maximal number of cached records, only caches media type and Path, not the content
-