Class StaticContentService.Builder<B extends StaticContentService.Builder<B>>
java.lang.Object
io.helidon.webserver.staticcontent.StaticContentService.Builder<B>
- Type Parameters:
B
- type of a subclass of a concrete builder
- All Implemented Interfaces:
Builder<B,
,StaticContentService> Supplier<StaticContentService>
- Direct Known Subclasses:
StaticContentService.FileBasedBuilder
- Enclosing interface:
StaticContentService
public abstract static class StaticContentService.Builder<B extends StaticContentService.Builder<B>>
extends Object
implements Builder<B,StaticContentService>
Fluent builder of the StaticContent detailed parameters.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddCacheInMemory
(String path) Add a path (as requested by the user) that should be cached in memory.final StaticContentService
build()
Build the instance from this builder.protected abstract StaticContentService
doBuild()
Build the actual instance.pathMapper
(Function<String, String> resolvePathFunction) Map request path to resource path.recordCacheCapacity
(int capacity) Configure capacity of cache used for resources.welcomeFileName
(String welcomeFileName) Sets a name of the "file" which will be returned if directory is requested.
-
Constructor Details
-
Builder
protected Builder()Default constructor.
-
-
Method Details
-
build
Description copied from interface:Builder
Build the instance from this builder.- Specified by:
build
in interfaceBuilder<B extends StaticContentService.Builder<B>,
StaticContentService> - Returns:
- instance of the built type
-
welcomeFileName
Sets a name of the "file" which will be returned if directory is requested.- Parameters:
welcomeFileName
- a name of the welcome file- Returns:
- updated builder
-
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.- Parameters:
resolvePathFunction
- function- Returns:
- updated builder
-
addCacheInMemory
Add a path (as requested by the user) that should be cached in memory. The resource will be loaded into memory (as bytes) on server startup and served from memory, instead of accessing the resource each time. For classpath, each file must be explicitly specified (as we do not scan classpath), for file based this can also include directories. Helidon does not validate amount of memory used, be careful to have enough heap memory to cache the configured files.Files cached in memory will never be re-loaded, even if changed, until server restart!
For classpath resource served from
web/index.html
, thepath
should be configured toindex.html
when the classpath root is set toweb
.- Parameters:
path
- path to cache in memory- Returns:
- updated builder
-
recordCacheCapacity
Configure capacity of cache used for resources. This cache will make sure the media type and location is discovered faster.- Parameters:
capacity
- maximal number of cached records, only caches media type and Path, not the content- Returns:
- updated builder
-
doBuild
Build the actual instance.- Returns:
- static content support
-