Seastar
High performance C++ framework for concurrent servers
|
The file handler get a path to a file on the disk in the constructor. it will always return the content of the file.
#include <seastar/http/file_handler.hh>
Public Member Functions | |
file_handler (const sstring &file, file_transformer *transformer=nullptr, bool force_path=true) | |
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) |
void | verify_mandatory_params (const http::request &req) const |
Static Public Member Functions | |
static sstring | get_extension (const sstring &file) |
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 |
|
inlineexplicit |
The file handler map a file to a url
file | the full path to the file on the disk |
transformer | an optional file transformer |
force_path | check if redirect is needed upon handle |
|
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 |
|
inlineinherited |
Check if all mandatory parameters exist in the request. if any param does not exist, the function would throw a missing_param_exception
params | req the http request |