asset_route | R Documentation |
An asset_route()
is fundamentally different than the other routes provided
by routr. Conceptually it is akin to ressource_route()
in that it is used
for serving static file content, but this route 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. The choice between asset_route()
and
ressource_route()
thus depends on your needs.
asset_route(
at,
path,
use_index = TRUE,
fallthrough = FALSE,
html_charset = "utf-8",
headers = list(),
validation = NULL,
except = NULL
)
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 |
fallthrough |
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 |
An optional validation pattern. Presently, the only type of
validation supported is an exact string match of a header. For example, if
|
except |
One or more url paths that should be excluded from the route.
Requests matching these will enter the standard router dispatch. The paths
are interpreted as subpaths to |
An AssetRoute object
Other Route constructors:
openapi_route()
,
ressource_route()
,
shared_secret_route()
,
sizelimit_route()
asset_route("/wd", "./", except = "/private")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.