StaticFiles class
Handler for returning static files and directory listings.
The handler expects a single wildcard path parameter, which it uses to determine which file/directory under the base directory to return.
Example:
var sf = StaticFiles("/var/www/myfiles",
defaultFilenames: ["index.html", "index.htm"]);
srv.pipelines.first.get("~/myfiles/*", sf.handler);
Known issues
- The encoding of text and HTML files (where the filenames end with .txt, .html or .htm) must be UTF-8.
Constructors
Properties
- allowDirectoryListing ↔ bool
-
Permit listing of directory contents.
getter/setter pair
- allowFilePathsAsDirectories ↔ bool
-
Interpret paths that do not end in slash as directory if not a file.
getter/setter pair
- baseDir → String
-
The directory under which to look for files.
no setter
-
defaultFilenames
→ List<
String> -
Names of files to try to find if a directory is requested.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
mimeTypes
↔ Map<
String, ContentType> -
Local MIME types specific to this object.
getter/setter pair
- publicServerUrl ↔ String
-
Public URL used by browsers to send requests to the server.
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- throwNotFoundExceptions ↔ bool
-
Controls whether "not found exceptions" are thrown or not.
getter/setter pair
Methods
-
directoryListing(
Request req, Directory dir, {required bool linkToParent}) → Future< Response> - Method used to generate a directory listing.
-
handler(
Request req) → Future< Response> - Request handler.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
-
defaultMimeTypes
↔ Map<
String, ContentType> -
Default MIME types.
getter/setter pair
Constants
-
standardFilenames
→ const List<
String> - Standard directory files.