Seastar
High performance C++ framework for concurrent servers
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
seastar::httpd::file_interaction_handler Class Referenceabstract

Detailed Description

A base class for handlers that interact with files. directory and file handlers both share some common logic with regards to file handling. they both needs to read a file from the disk, optionally transform it, and return the result or page not found on error

#include <seastar/http/file_handler.hh>

Inheritance diagram for seastar::httpd::file_interaction_handler:
seastar::httpd::handler_base seastar::httpd::directory_handler seastar::httpd::file_handler

Public Member Functions

 file_interaction_handler (file_transformer *p=nullptr)
 
file_interaction_handlerset_transformer (file_transformer *t)
 
bool redirect_if_needed (const http::request &req, http::reply &rep) const
 
virtual future< std::unique_ptr< http::reply > > handle (const sstring &path, std::unique_ptr< http::request > req, std::unique_ptr< http::reply > rep)=0
 
handler_basemandatory (const sstring &param)
 

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_transformertransformer
 

Member Function Documentation

◆ get_extension()

static sstring seastar::httpd::file_interaction_handler::get_extension ( const sstring &  file)
static

A helper method that returns the file extension.

Parameters
filethe file to check
Returns
the file extension

◆ handle()

virtual future<std::unique_ptr<http::reply> > seastar::httpd::handler_base::handle ( const sstring &  path,
std::unique_ptr< http::request req,
std::unique_ptr< http::reply rep 
)
pure virtualinherited

All handlers should implement this method. It fill the reply according to the request.

Parameters
paththe url path used in this call
reqthe original request
repthe reply

Implemented in seastar::httpd::function_handler, seastar::httpd::file_handler, seastar::httpd::directory_handler, seastar::httpd::api_registry_20, and seastar::httpd::api_registry.

◆ mandatory()

handler_base& seastar::httpd::handler_base::mandatory ( const sstring &  param)
inlineinherited

Add a mandatory parameter

Parameters
parama parameter name
Returns
a reference to the handler

◆ read()

future<std::unique_ptr<http::reply> > seastar::httpd::file_interaction_handler::read ( sstring  file,
std::unique_ptr< http::request req,
std::unique_ptr< http::reply rep 
)
protected

read a file from the disk and return it in the replay.

Parameters
filethe full path to a file on the disk
reqthe reuest
repthe reply

◆ redirect_if_needed()

bool seastar::httpd::file_interaction_handler::redirect_if_needed ( const http::request req,
http::reply rep 
) const

if the url ends without a slash redirect

Parameters
reqthe request
repthe reply
Returns
true on redirect

◆ set_transformer()

file_interaction_handler* seastar::httpd::file_interaction_handler::set_transformer ( file_transformer t)
inline

Allows setting a transformer to be used with the files returned.

Parameters
tthe file transformer to use
Returns
this

The documentation for this class was generated from the following file: