Seastar
High performance C++ framework for concurrent servers
|
The directory handler get a disk path in the constructor. and expect a path parameter in the handle method. it would concatenate the two and return the file e.g. if the path is /usr/mgmt/public in the path parameter is index.html handle will return the content of /usr/mgmt/public/index.html
#include <seastar/http/file_handler.hh>
Public Member Functions | |
directory_handler (const sstring &doc_root, file_transformer *transformer=nullptr) | |
future< std::unique_ptr< http::reply > > | handle (const sstring &path, std::unique_ptr< http::request > req, std::unique_ptr< http::reply > rep) override |
file_interaction_handler * | set_transformer (file_transformer *t) |
bool | redirect_if_needed (const http::request &req, http::reply &rep) const |
handler_base & | mandatory (const sstring ¶m) |
Static Public Member Functions | |
static sstring | get_extension (const sstring &file) |
Public Attributes | |
std::vector< sstring > | _mandatory_param |
Protected Member Functions | |
future< std::unique_ptr< http::reply > > | read (sstring file, std::unique_ptr< http::request > req, std::unique_ptr< http::reply > rep) |
output_stream< char > | get_stream (std::unique_ptr< http::request > req, const sstring &extension, output_stream< char > &&s) |
Protected Attributes | |
file_transformer * | transformer |
|
explicit |
The directory handler map a base path and a path parameter to a file
doc_root | the root directory to search the file from. |
transformer | an optional file transformer For example if the root is '/usr/mgmt/public' and the path parameter will be '/css/style.css' the file wil be /usr/mgmt/public/css/style.css' |
|
staticinherited |
A helper method that returns the file extension.
file | the file to check |
|
overridevirtual |
All handlers should implement this method. It fill the reply according to the request.
path | the url path used in this call |
req | the original request |
rep | the reply |
Implements seastar::httpd::handler_base.
|
inlineinherited |
Add a mandatory parameter
param | a parameter name |
|
protectedinherited |
read a file from the disk and return it in the replay.
file | the full path to a file on the disk |
req | the reuest |
rep | the reply |
|
inherited |
if the url ends without a slash redirect
req | the request |
rep | the reply |
|
inlineinherited |
Allows setting a transformer to be used with the files returned.
t | the file transformer to use |