|
libcex
1.0.0
Modern C++11 embedded webserver library
|
Filesystem middleware function. More...
Go to the source code of this file.
Classes | |
| struct | cex::FilesystemOptions |
| Contains all options for the filesystem middleware. More... | |
Functions | |
| MiddlewareFunction | cex::filesystem (std::string aPath) |
| Creates a middleware that loads files from the filesystem with the given path as rootPath. More... | |
| MiddlewareFunction | cex::filesystem (std::shared_ptr< FilesystemOptions > opts=nullptr) |
| Creates a middleware that loads files from the filesystem with the given options object. More... | |
Filesystem middleware function.
Loads file contents from the local filesystem with the paths provided by the request URLs.
Example:
The Content-Type header is set accordingly for the mimetype of the queried file. The mimetype is determined by the file extension in the request-URL. libcex contains a list of known mimetypes to look up the exact Content-Type as well as binary/text information.
The defaultEncoding is added to the Content-Type if it was set and the determined mimetype is not a binary type.
If no mimetype could be found in the internal list, Content-Type falls back to text/plain with the defaultEncoding.
| MiddlewareFunction cex::filesystem | ( | std::string | aPath | ) |
Creates a middleware that loads files from the filesystem with the given path as rootPath.
| path | The path to use as rootPath |
The path of request URLs will be appended as relative paths when accessing files .
| MiddlewareFunction cex::filesystem | ( | std::shared_ptr< FilesystemOptions > | opts = nullptr | ) |
Creates a middleware that loads files from the filesystem with the given options object.
| opts | The FilesystemOptions object containing rootPath and defaultEncoding |
The path of request URLs will be appended as relative paths when accessing files .
1.8.16