StaticRoute.directory constructor
StaticRoute.directory(
- Directory root, {
- CacheBustingConfig? cacheBustingConfig,
- CacheControlFactory? cacheControlFactory,
- String? host,
Use StaticRoute.directory to serve everything below a given root.
Use cacheControlFactory to customize what CacheControlHeader to
return for a given asset. Defaults to the value of
SERVERPOD_WEB_SERVER_STATIC_CACHE_CONTROL, or leaving caching behavior
to client side heuristics when the environment variable is not set.
An explicit cacheControlFactory takes precedence over the value of the
SERVERPOD_WEB_SERVER_STATIC_CACHE_CONTROL environment variable.
The host parameter restricts this route to a specific virtual host
(defaults to null, matching any host).
Implementation
factory StaticRoute.directory(
Directory root, {
CacheBustingConfig? cacheBustingConfig,
CacheControlFactory? cacheControlFactory,
String? host,
}) {
return StaticRoute._(
StaticHandler.directory(
root,
cacheBustingConfig: cacheBustingConfig,
cacheControl:
cacheControlFactory ??
cacheControlFactoryFromEnvironment(
_staticCacheControlEnvironmentVariable,
fallback: noCacheControl,
),
).asHandler,
tailMatch: true,
host: host,
);
}