Package com.linecorp.armeria.server.file
Class FileServiceBuilder
java.lang.Object
com.linecorp.armeria.server.file.FileServiceBuilder
public final class FileServiceBuilder extends Object
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 Type Method Description FileServiceBuilder
addHeader(CharSequence name, Object value)
Adds the specified HTTP header.FileServiceBuilder
addHeaders(Iterable<? extends Map.Entry<? extends CharSequence,?>> headers)
Adds the specified HTTP headers.FileServiceBuilder
autoIndex(boolean autoIndex)
Sets whetherFileService
auto-generates a directory listing for a directory without anindex.html
file.FileService
build()
Returns a newly-createdFileService
based on the properties of this builder.FileServiceBuilder
cacheControl(CacheControl cacheControl)
Sets the"cache-control"
header.FileServiceBuilder
cacheControl(CharSequence cacheControl)
Sets the"cache-control"
header.FileServiceBuilder
clock(Clock clock)
Sets theClock
that provides the current date and time.FileServiceBuilder
entryCacheSpec(String entryCacheSpec)
Sets the cache spec for caching file entries.FileServiceBuilder
maxCacheEntries(int maxCacheEntries)
Sets the maximum allowed number of cached file entries.FileServiceBuilder
maxCacheEntrySizeBytes(int maxCacheEntrySizeBytes)
Sets the maximum allowed size of a cached file entry.FileServiceBuilder
serveCompressedFiles(boolean serveCompressedFiles)
Sets whether pre-compressed files should be served.FileServiceBuilder
setHeader(CharSequence name, Object value)
Sets the specified HTTP header.FileServiceBuilder
setHeaders(Iterable<? extends Map.Entry<? extends CharSequence,?>> headers)
Sets the specified HTTP headers.String
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 cache spec for caching file entries. If not set,"maximumSize=1024"
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
-