Import std.net.http.files
std.net.http.files
Static files: a folder's files as a router's routes, for GET and HEAD, with their Content-Type, ETag, and Last-Modified, a 304 Not Modified for a request whose copy is current, and a 206 Partial Content for a request for one range of a file's bytes.
std/net/http/files.fb
Extends
HttpRouter
extend
Extend HttpRouter
No doc comment.
std/net/http/files.fb, line 24
-
Serves
folder's files atprefix, a path as routes have them, without a *name, or "/" for the router's own: a GET or a HEAD ofprefix/a/b.png givesfolder's a/b.png, and one of a folder gives its index.html, once its path ends with '/', to which one that doesn't is redirected. A segment that starts with a '.', or has a '', a ':', or a control character, or ends with a '.' or a space, or is a name Windows keeps for a device, like NUL or COM1, is a 404, as is what isn't there, whatever the OS; and so is a file whose path on the disk, its links followed and its names the disk's own, isn't inside thefolder's, or has such a name there, as a link out of thefolder, or Windows' 8.3 short name SECRET~1 for .secret, would; so a request never reaches outside thefolder, nor a name it refuses. A file of more than 2 GiB, which it reads whole, is a 500. Panics whenprefixisn't a path, or a route has its paths already.
Report an issue with this page or with FutureBlitz on GitHub.