public final class HttpFileServiceBuilder extends Object
HttpFileService and its HttpFileServiceConfig. Use the factory methods in
HttpFileService if you do not override the default settings.| Modifier and Type | Method and Description |
|---|---|
HttpFileServiceBuilder |
addHeader(CharSequence name,
Object value)
Adds the specified HTTP header.
|
HttpFileServiceBuilder |
addHeaders(Iterable<? extends Map.Entry<? extends CharSequence,?>> headers)
Adds the specified HTTP headers.
|
HttpFileServiceBuilder |
autoIndex(boolean autoIndex)
Sets whether
HttpFileService auto-generates a directory listing for a directory without an
index.html file. |
HttpFileService |
build()
Returns a newly-created
HttpFileService based on the properties of this builder. |
HttpFileServiceBuilder |
cacheControl(CacheControl cacheControl)
Sets the
"cache-control" header. |
HttpFileServiceBuilder |
cacheControl(CharSequence cacheControl)
Sets the
"cache-control" header. |
HttpFileServiceBuilder |
clock(Clock clock)
Sets the
Clock that provides the current date and time. |
HttpFileServiceBuilder |
entryCacheSpec(String entryCacheSpec)
Sets the cache spec for caching file entries.
|
static HttpFileServiceBuilder |
forClassPath(ClassLoader classLoader,
String rootDir)
Creates a new
HttpFileServiceBuilder with the specified rootDir in the current class
path. |
static HttpFileServiceBuilder |
forClassPath(String rootDir)
Creates a new
HttpFileServiceBuilder with the specified rootDir in the current class
path. |
static HttpFileServiceBuilder |
forFileSystem(Path rootDir)
Creates a new
HttpFileServiceBuilder with the specified rootDir in an O/S file system. |
static HttpFileServiceBuilder |
forFileSystem(String rootDir)
Creates a new
HttpFileServiceBuilder with the specified rootDir in an O/S file system. |
static HttpFileServiceBuilder |
forVfs(HttpVfs vfs)
Creates a new
HttpFileServiceBuilder with the specified HttpVfs. |
HttpFileServiceBuilder |
maxCacheEntries(int maxCacheEntries)
Sets the maximum allowed number of cached file entries.
|
HttpFileServiceBuilder |
maxCacheEntrySizeBytes(int maxCacheEntrySizeBytes)
Sets the maximum allowed size of a cached file entry.
|
HttpFileServiceBuilder |
serveCompressedFiles(boolean serveCompressedFiles)
Sets whether pre-compressed files should be served.
|
HttpFileServiceBuilder |
setHeader(CharSequence name,
Object value)
Sets the specified HTTP header.
|
HttpFileServiceBuilder |
setHeaders(Iterable<? extends Map.Entry<? extends CharSequence,?>> headers)
Sets the specified HTTP headers.
|
String |
toString() |
public static HttpFileServiceBuilder forFileSystem(String rootDir)
HttpFileServiceBuilder with the specified rootDir in an O/S file system.public static HttpFileServiceBuilder forFileSystem(Path rootDir)
HttpFileServiceBuilder with the specified rootDir in an O/S file system.public static HttpFileServiceBuilder forClassPath(String rootDir)
HttpFileServiceBuilder with the specified rootDir in the current class
path.public static HttpFileServiceBuilder forClassPath(ClassLoader classLoader, String rootDir)
HttpFileServiceBuilder with the specified rootDir in the current class
path.public static HttpFileServiceBuilder forVfs(HttpVfs vfs)
HttpFileServiceBuilder with the specified HttpVfs.public HttpFileServiceBuilder clock(Clock clock)
Clock that provides the current date and time.public HttpFileServiceBuilder maxCacheEntries(int maxCacheEntries)
1024 entries
are cached by default.public HttpFileServiceBuilder entryCacheSpec(String entryCacheSpec)
"maximumSize=1024" is used by default.public HttpFileServiceBuilder serveCompressedFiles(boolean serveCompressedFiles)
HttpFileService 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 HttpFileServiceBuilder maxCacheEntrySizeBytes(int maxCacheEntrySizeBytes)
public HttpFileServiceBuilder autoIndex(boolean autoIndex)
HttpFileService 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 HttpFileServiceBuilder addHeader(CharSequence name, Object value)
public HttpFileServiceBuilder addHeaders(Iterable<? extends Map.Entry<? extends CharSequence,?>> headers)
public HttpFileServiceBuilder setHeader(CharSequence name, Object value)
public HttpFileServiceBuilder setHeaders(Iterable<? extends Map.Entry<? extends CharSequence,?>> headers)
public HttpFileServiceBuilder cacheControl(CacheControl cacheControl)
"cache-control" header. This method is a shortcut of:
builder.setHeader(HttpHeaderNames.CACHE_CONTROL, cacheControl);
public HttpFileServiceBuilder cacheControl(CharSequence cacheControl)
"cache-control" header. This method is a shortcut of:
builder.setHeader(HttpHeaderNames.CACHE_CONTROL, cacheControl);
public HttpFileService build()
HttpFileService based on the properties of this builder.Copyright © 2020 LeanCloud. All rights reserved.