A class for serving files from the server directly. The AssetRoute
is
fundamentally different than the other routes provided by routr. It is
specific to httpuv and circumvents the standard dispatch entirely (the
request never enters the R process). This makes it extremely fast but also
somewhat limited as you can't pass the request through any middleware.
Active bindings
at
The url path to serve the assets on
path
The path to the file or directory to serve
use_index
Should an
index.html
file be served if present when a client requests the folderfallthrough
Should requests that doesn't match a file enter the request loop or have a 404 response send directly
html_charset
The charset to report when serving html files
headers
A list of headers to add to the response.
validation
An optional validation pattern to compare to the request headers
except
One or more url paths that should be excluded from this route
name
An autogenerated name for the asset route
Methods
Method new()
Create a new AssetRoute
Usage
AssetRoute$new(
at,
path,
use_index = TRUE,
fallthrough = FALSE,
html_charset = "utf-8",
headers = list(),
validation = NULL,
except = NULL
)
Arguments
at
The url path to listen to requests on
path
The path to the file or directory on the file system
use_index
Should an
index.html
file be served if present when a client requests the folderfallthrough
Should requests that doesn't match a file enter the request loop or have a 404 response send directly
html_charset
The charset to report when serving html files
headers
A list of headers to add to the response. Will be combined with the global headers of the app
validation
A string for validating incoming requests. See httpuv::staticPath
except
One or more url paths that should be excluded from the route. Requests matching these will enter the standard router dispatch
Method on_attach()
Method for use by fiery
when attached as a plugin. Should
not be called directly. This method creates a RouteStack with the asset
route as the single route and then mounts that to the app. For more
flexibility create the RouteStack manually