public class FileServiceBuilder extends Object
FileService and its FileServiceConfig. Use the factory methods in
FileService if you do not override the default settings.| Modifier and Type | Method and 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 whether
FileService auto-generates a directory listing for a directory without an
index.html file. |
FileService |
build()
Returns a newly-created
FileService 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 the
Clock 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() |
public FileServiceBuilder clock(Clock clock)
Clock that provides the current date and time.public FileServiceBuilder maxCacheEntries(int maxCacheEntries)
1024 entries
are cached by default.public FileServiceBuilder entryCacheSpec(String entryCacheSpec)
"maximumSize=1024" is used by default.public FileServiceBuilder serveCompressedFiles(boolean serveCompressedFiles)
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 serve index.js either
raw, gzip-compressed, or brotli-compressed, there should be three files, index.js,
index.js.gz, and index.js.br. By default, this feature is disabled.
Some tools for precompressing resources during a build process include gulp-zopfli and
gulp-brotli, which by default create files with the correct extension.
public FileServiceBuilder maxCacheEntrySizeBytes(int maxCacheEntrySizeBytes)
public FileServiceBuilder autoIndex(boolean autoIndex)
FileService auto-generates a directory listing for a directory without an
index.html file. By default, this feature is disabled. Consider the security implications of
when enabling this feature.public FileServiceBuilder addHeader(CharSequence name, Object value)
public FileServiceBuilder addHeaders(Iterable<? extends Map.Entry<? extends CharSequence,?>> headers)
public FileServiceBuilder setHeader(CharSequence name, Object value)
public FileServiceBuilder setHeaders(Iterable<? extends Map.Entry<? extends CharSequence,?>> headers)
public FileServiceBuilder cacheControl(CacheControl cacheControl)
"cache-control" header. This method is a shortcut for:
builder.setHeader(HttpHeaderNames.CACHE_CONTROL, cacheControl);
public FileServiceBuilder cacheControl(CharSequence cacheControl)
"cache-control" header. This method is a shortcut for:
builder.setHeader(HttpHeaderNames.CACHE_CONTROL, cacheControl);
public FileService build()
FileService based on the properties of this builder.Copyright © 2020 LeanCloud. All rights reserved.