Static Public Member Functions | Public Member Functions | List of all members
HttpWebApp Class Referenceabstract

Abstract base class of HTTP web application handlers. More...

#include <HttpWebApp.hpp>

Inheritance diagram for HttpWebApp:
[legend]

Static Public Member Functions

static EmptyResponse createBadRequestHeadResponse (HttpSession &session, const StringRequest &request)
 Create a bad request response for a head request. More...
 
static StringResponse createBadRequestResponse (HttpSession &session, const StringRequest &request, std::string_view errorMessage)
 Create a bad request response. More...
 
static EmptyResponse createNotFoundHeadResponse (HttpSession &session, const StringRequest &request)
 Create a not found response for a head request. More...
 
static StringResponse createNotFoundStringResponse (HttpSession &session, const StringRequest &request)
 Create a not found response. More...
 
static EmptyResponse createOkHeadResponse (HttpSession &session, const StringRequest &request)
 Create an empty 200 response for a head request. More...
 
static StringResponse createOkResponse (HttpSession &session, const StringRequest &request)
 Create an empty 200 response. More...
 
static EmptyResponse createPermanentRedirectResponse (HttpSession &session, const StringRequest &request, std::string_view location)
 Create a permanent redirect response. More...
 
static EmptyResponse createRedirectResponse (HttpSession &session, const StringRequest &request, std::string_view location)
 Create a redirect response. More...
 
static EmptyResponse createServerErrorHeadResponse (HttpSession &session, const StringRequest &request)
 Create a server error response for a head request. More...
 
static StringResponse createServerErrorResponse (HttpSession &session, const StringRequest &request, std::string_view errorMessage)
 Create a server error response. More...
 
template<typename WebAppT >
static void registerHttpWebApp (const std::string &name)
 Register an HTTP web application. More...
 

Public Member Functions

virtual ~HttpWebApp ()=default
 Destroy the HTTP web application instance. More...
 
virtual void handleGetRequest (HttpSession &session, const StringRequest &request, std::map< std::string, std::string > &variables)=0
 Handle a GET request. More...
 
virtual void handleHeadRequest (HttpSession &session, const StringRequest &request, std::map< std::string, std::string > &variables)=0
 Handle a HEAD request. More...
 
virtual void handlePostRequest (HttpSession &session, const StringRequest &request, std::map< std::string, std::string > &variables)=0
 Handle a POST request. More...
 

Detailed Description

Abstract base class of HTTP web application handlers.

All concrete HTTP web applications must have a constructor of the following signature:

const EnvironmentProperties & configuration

This constructor will be used to instantiate the web application during initialisation of the HTTP server.

This class also contains some canned responses for use in handler implementations.

Constructor & Destructor Documentation

◆ ~HttpWebApp()

virtual ~HttpWebApp ( )
virtualdefault

Destroy the HTTP web application instance.

Member Function Documentation

◆ createBadRequestHeadResponse()

static EmptyResponse createBadRequestHeadResponse ( HttpSession session,
const StringRequest request 
)
static

Create a bad request response for a head request.

◆ createBadRequestResponse()

static StringResponse createBadRequestResponse ( HttpSession session,
const StringRequest request,
std::string_view  errorMessage 
)
static

Create a bad request response.

◆ createNotFoundHeadResponse()

static EmptyResponse createNotFoundHeadResponse ( HttpSession session,
const StringRequest request 
)
static

Create a not found response for a head request.

◆ createNotFoundStringResponse()

static StringResponse createNotFoundStringResponse ( HttpSession session,
const StringRequest request 
)
static

Create a not found response.

◆ createOkHeadResponse()

static EmptyResponse createOkHeadResponse ( HttpSession session,
const StringRequest request 
)
static

Create an empty 200 response for a head request.

◆ createOkResponse()

static StringResponse createOkResponse ( HttpSession session,
const StringRequest request 
)
static

Create an empty 200 response.

◆ createPermanentRedirectResponse()

static EmptyResponse createPermanentRedirectResponse ( HttpSession session,
const StringRequest request,
std::string_view  location 
)
static

Create a permanent redirect response.

◆ createRedirectResponse()

static EmptyResponse createRedirectResponse ( HttpSession session,
const StringRequest request,
std::string_view  location 
)
static

Create a redirect response.

◆ createServerErrorHeadResponse()

static EmptyResponse createServerErrorHeadResponse ( HttpSession session,
const StringRequest request 
)
static

Create a server error response for a head request.

◆ createServerErrorResponse()

static StringResponse createServerErrorResponse ( HttpSession session,
const StringRequest request,
std::string_view  errorMessage 
)
static

Create a server error response.

◆ handleGetRequest()

virtual void handleGetRequest ( HttpSession session,
const StringRequest request,
std::map< std::string, std::string > &  variables 
)
pure virtual

Handle a GET request.

The supplied session provides shared server state and the sendResponse method.

Parameters
sessionthe HTTP session object, also containing the client session
requestthe HTTP request object
variablesthe request variables that are generated and consumed during the request

Implemented in EmailSendingHttpWebApp, RoutingHttpWebApp, CannedHttpWebApp, RedirectingHttpWebApp, FileServingHttpWebApp, and ConfigurationWebApp.

◆ handleHeadRequest()

virtual void handleHeadRequest ( HttpSession session,
const StringRequest request,
std::map< std::string, std::string > &  variables 
)
pure virtual

Handle a HEAD request.

The supplied session provides shared server state and the sendResponse method.

Parameters
sessionthe HTTP session object, also containing the client session
requestthe HTTP request object
variablesthe request variables that are generated and consumed during the request

Implemented in EmailSendingHttpWebApp, RoutingHttpWebApp, CannedHttpWebApp, RedirectingHttpWebApp, FileServingHttpWebApp, and ConfigurationWebApp.

◆ handlePostRequest()

virtual void handlePostRequest ( HttpSession session,
const StringRequest request,
std::map< std::string, std::string > &  variables 
)
pure virtual

Handle a POST request.

The supplied session provides shared server state and the sendResponse method.

Parameters
sessionthe HTTP session object, also containing the client session
requestthe HTTP request object
variablesthe request variables that are generated and consumed during the request

Implemented in EmailSendingHttpWebApp, RoutingHttpWebApp, CannedHttpWebApp, RedirectingHttpWebApp, FileServingHttpWebApp, and ConfigurationWebApp.

◆ registerHttpWebApp()

static void registerHttpWebApp ( const std::string &  name)
inlinestatic

Register an HTTP web application.

Template Parameters
theHTTP web application type
Parameters
namethe name of the composite property that provides the web app's configuration

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