vertx / io.vertx.ext.web.handler / StaticHandler

# StaticHandler

`interface StaticHandler : Handler<RoutingContext>`

A handler for serving static resources from the file system or classpath.

Author
Tim Fox

### Properties

DEFAULT_ALWAYS_ASYNC_FS | `static val DEFAULT_ALWAYS_ASYNC_FS: Boolean` Default of whether async filesystem access should always be used
DEFAULT_CACHE_ENTRY_TIMEOUT | `static val DEFAULT_CACHE_ENTRY_TIMEOUT: Long` Default cache entry timeout, when caching
DEFAULT_CACHING_ENABLED | `static val DEFAULT_CACHING_ENABLED: Boolean` Default of whether cache header handling is enabled
DEFAULT_DIRECTORY_LISTING | `static val DEFAULT_DIRECTORY_LISTING: Boolean` Default of whether directory listing is enabled
DEFAULT_DIRECTORY_TEMPLATE | `static val DEFAULT_DIRECTORY_TEMPLATE: String` Default template file to use for directory listing
DEFAULT_ENABLE_FS_TUNING | `static val DEFAULT_ENABLE_FS_TUNING: Boolean` Default of whether fs async/sync tuning should be used
DEFAULT_FILES_READ_ONLY | `static val DEFAULT_FILES_READ_ONLY: Boolean` Default value of whether files are read -only and never will be updated
DEFAULT_INCLUDE_HIDDEN | `static val DEFAULT_INCLUDE_HIDDEN: Boolean` Default of whether hidden files can be served
DEFAULT_INDEX_PAGE | `static val DEFAULT_INDEX_PAGE: String` The default index page
DEFAULT_MAX_AGE_SECONDS | `static val DEFAULT_MAX_AGE_SECONDS: Long` Default max age for cache headers
DEFAULT_MAX_AVG_SERVE_TIME_NS | `static val DEFAULT_MAX_AVG_SERVE_TIME_NS: Long` Default max avg serve time, in ns, over which serving will be considered slow
DEFAULT_MAX_CACHE_SIZE | `static val DEFAULT_MAX_CACHE_SIZE: Int` The default max cache size
DEFAULT_RANGE_SUPPORT | `static val DEFAULT_RANGE_SUPPORT: Boolean` Default of whether Range request handling support should be used
DEFAULT_ROOT_FILESYSTEM_ACCESS | `static val DEFAULT_ROOT_FILESYSTEM_ACCESS: Boolean` Default of whether access to the root of the file system should be allowed or just allow from the current working directory.
DEFAULT_SEND_VARY_HEADER | `static val DEFAULT_SEND_VARY_HEADER: Boolean` Default of whether vary header should be sent.
DEFAULT_WEB_ROOT | `static val DEFAULT_WEB_ROOT: String` Default value of the web-root, where files are served from

### Functions

create | `open static fun create(): StaticHandler` Create a handler using defaults `open static fun create(root: String): StaticHandler` Create a handler, specifying web-root `open static fun create(root: String, classLoader: ClassLoader): StaticHandler` Create a handler, specifying web-root and a classloader used to load the resources.
setAllowRootFileSystemAccess | `abstract fun setAllowRootFileSystemAccess(allowRootFileSystemAccess: Boolean): StaticHandler` Enable/Disable access to the root of the filesystem
setAlwaysAsyncFS | `abstract fun setAlwaysAsyncFS(alwaysAsyncFS: Boolean): StaticHandler` Set whether async filesystem access should always be used
setCacheEntryTimeout | `abstract fun setCacheEntryTimeout(timeout: Long): StaticHandler` Set the server cache entry timeout when caching is enabled
setCachingEnabled | `abstract fun setCachingEnabled(enabled: Boolean): StaticHandler` Set whether cache header handling is enabled
setDefaultContentEncoding | `abstract fun setDefaultContentEncoding(contentEncoding: String): StaticHandler` Set the default content encoding for text related files. This allows overriding the system settings default value.
setDirectoryListing | `abstract fun setDirectoryListing(directoryListing: Boolean): StaticHandler` Set whether directory listing is enabled
setDirectoryTemplate | `abstract fun setDirectoryTemplate(directoryTemplate: String): StaticHandler` Set the directory template to be used when directory listing
setEnableFSTuning | `abstract fun setEnableFSTuning(enableFSTuning: Boolean): StaticHandler` Set whether async/sync filesystem tuning should enabled
setEnableRangeSupport | `abstract fun setEnableRangeSupport(enableRangeSupport: Boolean): StaticHandler` Set whether range requests (resumable downloads; media streaming) should be enabled.
setFilesReadOnly | `abstract fun setFilesReadOnly(readOnly: Boolean): StaticHandler` Set whether files are read-only and will never change
setHttp2PushMapping | `abstract fun setHttp2PushMapping(http2PushMappings: MutableList<Http2PushMapping>): StaticHandler` Set the file mapping for http2push and link preload
setIncludeHidden | `abstract fun setIncludeHidden(includeHidden: Boolean): StaticHandler` Set whether hidden files should be served
setIndexPage | `abstract fun setIndexPage(indexPage: String): StaticHandler` Set the index page
setMaxAgeSeconds | `abstract fun setMaxAgeSeconds(maxAgeSeconds: Long): StaticHandler` Set value for max age in caching headers
setMaxAvgServeTimeNs | `abstract fun setMaxAvgServeTimeNs(maxAvgServeTimeNanoSeconds: Long): StaticHandler` Set the max serve time in ns, above which serves are considered slow
setMaxCacheSize | `abstract fun setMaxCacheSize(maxCacheSize: Int): StaticHandler` Set the max cache size, when caching is enabled
setSendVaryHeader | `abstract fun setSendVaryHeader(varyHeader: Boolean): StaticHandler` Set whether vary header should be sent with response.
setWebRoot | `abstract fun setWebRoot(webRoot: String): StaticHandler` Set the web root