Package com.jsgalactic.axiom.http
Class StaticFiles.Builder
java.lang.Object
com.jsgalactic.axiom.http.StaticFiles.Builder
- Enclosing class:
StaticFiles
Collects the immutable handler's configuration. Not shared until
build().-
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds the handler.cacheControl(String value) Sets theCache-Controlfield sent with every file.Sets the wildcard capture that holds the file path,pathby default.contentType(String extension, String contentType) Adds or replaces the content type of one lowercase extension.maxFileSize(long bytes) Sets the largest file this handler will serve, 64 MiB by default.
-
Method Details
-
capture
Sets the wildcard capture that holds the file path,pathby default.- Parameters:
name- capture name declared by the route template- Returns:
- this builder
- Throws:
IllegalArgumentException- if the name is not a capture identifier
-
maxFileSize
Sets the largest file this handler will serve, 64 MiB by default.- Parameters:
bytes- maximum representation length, positive and at most 1 TiB- Returns:
- this builder
- Throws:
IllegalArgumentException- if the bound is outside that range
-
cacheControl
Sets theCache-Controlfield sent with every file.- Parameters:
value- header value of 1 to 512 visible ASCII characters- Returns:
- this builder
- Throws:
IllegalArgumentException- if the value is empty, overlong or contains a control
-
contentType
Adds or replaces the content type of one lowercase extension. Overrides take precedence over the built-in table; extensions without an entry useStaticFiles.DEFAULT_CONTENT_TYPE.- Parameters:
extension- file extension without the dot, 1 to 16 ASCII letters or digitscontentType- exact media type with optional parameters- Returns:
- this builder
- Throws:
IllegalArgumentException- if the extension or content type is invalid
-
build
Builds the handler. The result holds no reference to this builder and may be shared.- Returns:
- immutable handler for GET and HEAD requests
-