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 = new StaticFiles("/var/www/myfiles",
                         defaultFilenames: ["index.html", "index.htm"]);

srv.pipelines.first.get("~/myfiles/*", sf.handler);

Constructors

StaticFiles(String baseDir, { List<String> defaultFilenames, bool allowFilePathsAsDirectories: true, bool allowDirectoryListing: false })
Constructor [...]

Properties

allowDirectoryListing ↔ bool
Permit listing of directory contents. [...]
read / write
allowFilePathsAsDirectories ↔ bool
Interpret paths that do not end in slash as directory if not a file. [...]
read / write
baseDir → String
The directory under which to look for files. [...]
read-only
defaultFilenames ↔ List<String>
Names of files to try to find if a directory is requested. [...]
read / write
mimeTypes ↔ Map<String, ContentType>
Local MIME types specific to this object. [...]
read / write
throwNotFoundExceptions ↔ bool
Controls whether "not found exceptions" are thrown or not. [...]
read / write
hashCode → int
The hash code for this object. [...]
read-only, inherited
runtimeType → Type
A representation of the runtime type of the object.
read-only, inherited

Methods

directoryListing(Request req, Directory dir, { 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 non-existent method or property is accessed. [...]
inherited
toString() → String
Returns a string representation of this object.
inherited

Operators

operator ==(dynamic other) → bool
The equality operator. [...]
inherited

Static Properties

defaultMimeTypes ↔ Map<String, ContentType>
Default MIME types. [...]
read / write