Package com.linecorp.armeria.server.file
Class FileServiceBuilder
java.lang.Object
com.linecorp.armeria.server.file.FileServiceBuilder
Builds a new
FileService
and its FileServiceConfig
. Use the factory methods in
FileService
if you do not override the default settings.-
Method Summary
Modifier and TypeMethodDescriptionaddHeader(CharSequence name, Object value)
Adds the specified HTTP header.addHeaders(Iterable<? extends Map.Entry<? extends CharSequence,?>> headers)
Adds the specified HTTP headers.autoIndex(boolean autoIndex)
Sets whetherFileService
auto-generates a directory listing for a directory without anindex.html
file.build()
Returns a newly-createdFileService
based on the properties of this builder.cacheControl(CacheControl cacheControl)
Sets the"cache-control"
header.cacheControl(CharSequence cacheControl)
Sets the"cache-control"
header.Sets theClock
that provides the current date and time.entryCacheSpec(String entryCacheSpec)
Sets the Caffeine specification string of the cache that stores the content of theHttpFile
s read by theFileService
.maxCacheEntries(int maxCacheEntries)
Sets the maximum allowed number of cached file entries.maxCacheEntrySizeBytes(int maxCacheEntrySizeBytes)
Sets the maximum allowed size of a cached file entry.serveCompressedFiles(boolean serveCompressedFiles)
Sets whether pre-compressed files should be served.setHeader(CharSequence name, Object value)
Sets the specified HTTP header.setHeaders(Iterable<? extends Map.Entry<? extends CharSequence,?>> headers)
Sets the specified HTTP headers.toString()
-
Method Details
-
clock
Sets theClock
that provides the current date and time. -
maxCacheEntries
Sets the maximum allowed number of cached file entries. If not set, up to1024
entries are cached by default. -
entryCacheSpec
Sets the Caffeine specification string of the cache that stores the content of theHttpFile
s read by theFileService
. If not set,Flags.fileServiceCacheSpec()
is used by default. -
serveCompressedFiles
Sets whether pre-compressed files should be served.FileService
supports serving files compressed with gzip, with the extension".gz"
, and brotli, with the extension".br"
. The extension should be appended to the original file. For example, to serveindex.js
either raw, gzip-compressed, or brotli-compressed, there should be three files,index.js
,index.js.gz
, andindex.js.br
. By default, this feature is disabled.Some tools for precompressing resources during a build process include
gulp-zopfli
andgulp-brotli
, which by default create files with the correct extension. -
maxCacheEntrySizeBytes
Sets the maximum allowed size of a cached file entry. The file bigger than this value will not be cached. If not set, 65536 is used by default. -
autoIndex
Sets whetherFileService
auto-generates a directory listing for a directory without anindex.html
file. By default, this feature is disabled. Consider the security implications of when enabling this feature. -
addHeader
Adds the specified HTTP header. -
addHeaders
public FileServiceBuilder addHeaders(Iterable<? extends Map.Entry<? extends CharSequence,?>> headers)Adds the specified HTTP headers. -
setHeader
Sets the specified HTTP header. -
setHeaders
public FileServiceBuilder setHeaders(Iterable<? extends Map.Entry<? extends CharSequence,?>> headers)Sets the specified HTTP headers. -
cacheControl
Sets the"cache-control"
header. This method is a shortcut for:builder.setHeader(HttpHeaderNames.CACHE_CONTROL, cacheControl);
-
cacheControl
Sets the"cache-control"
header. This method is a shortcut for:builder.setHeader(HttpHeaderNames.CACHE_CONTROL, cacheControl);
-
build
Returns a newly-createdFileService
based on the properties of this builder. -
toString
-