RouteStaticDirectory class
Route for serving a directory of static files.
Constructors
-
RouteStaticDirectory.new({required String serverDirectory, String? basePath, String? serveAsRootPath, List<
PathCacheMaxAge> ? pathCachePatterns}) -
Creates a static directory with the
serverDirectory
as its root. IfbasePath
is provided, the directory will be served from that path. IfpathCachePatterns
is provided, paths matching the requested patterns will be cached for the requested amount of time. Paths that are do not match any provided pattern are cached for one year.
Properties
- basePath → String?
-
The path to the directory to serve static files from.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- method → RouteMethod
-
The method this route will respond to, i.e. HTTP get or post.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- serveAsRootPath → String?
-
The path to serve as the root path ('/'), e.g. '/index.html'.
final
- serverDirectory → String
-
The path to the directory to serve relative to the web/ directory.
final
Methods
-
handleCall(
Session session, HttpRequest request) → Future< bool> -
Handles a call to this route. This method is responsible for setting
a correct response headers, status code, and write the response body to
request.response
.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
setHeaders(
HttpHeaders headers) → void -
Sets the headers of the response. Default is text/html with UTF-8
encoding.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited