ofxHTTP
A collection of tools for HTTP.
ofx::HTTP::BaseRoute_< SettingsType > Class Template Reference

The base implmentation of a server route. More...

#include <BaseRoute.h>

Inheritance diagram for ofx::HTTP::BaseRoute_< SettingsType >:
ofx::HTTP::AbstractRoute ofx::HTTP::AbstractHTTPRequestHandler ofx::HTTP::AbstractHTTPRequestHandlerFactory ofx::HTTP::AbstractServerEventRequestHandler

Public Member Functions

 BaseRoute_ (const SettingsType &settings=SettingsType())
 Create a BaseRoute. More...
 
virtual ~BaseRoute_ ()
 Destroy a BaseRoute.
 
virtual void setup (const SettingsType &settings)
 Setup the route with settings. More...
 
virtual std::string routePathPattern () const override
 Get the route's regex path pattern. More...
 
virtual bool canHandleRequest (const Poco::Net::HTTPServerRequest &request, bool isSecurePort) const override
 Determine if this route can handle the given request. More...
 
virtual Poco::Net::HTTPRequestHandler * createRequestHandler (const Poco::Net::HTTPServerRequest &request) override
 Creates a new HTTPRequestHandler for the given request. More...
 
void handleRequest (Poco::Net::HTTPServerRequest &request, Poco::Net::HTTPServerResponse &response) override
 
virtual void handleRequest (ServerEventArgs &evt) override
 Handle the ServerEventArgs. More...
 
virtual void stop () override
 Stop any pending activity and close this route. More...
 
const SettingsType & settings () const
 
AbstractServergetServer () override
 
void setServer (AbstractServer *server) override
 Set the server that owns this route. More...
 
- Public Member Functions inherited from ofx::HTTP::AbstractRoute
virtual ~AbstractRoute ()
 Destroy the AbstractRoute instance.
 
- Public Member Functions inherited from ofx::HTTP::AbstractHTTPRequestHandler
virtual ~AbstractHTTPRequestHandler ()
 Destroy the AbstractHTTPRequestHandler.
 
- Public Member Functions inherited from ofx::HTTP::AbstractServerEventRequestHandler
virtual ~AbstractServerEventRequestHandler ()
 Destroy the AbstractServerEventRequestHandler.
 
- Public Member Functions inherited from ofx::HTTP::AbstractHTTPRequestHandlerFactory
virtual ~AbstractHTTPRequestHandlerFactory ()
 Destroy the AbstractHTTPRequestHandlerFactory.
 

Protected Attributes

SettingsType _settings
 The settings.
 
AbstractServer_server = nullptr
 A pointer to the server.
 

Detailed Description

template<typename SettingsType>
class ofx::HTTP::BaseRoute_< SettingsType >

The base implmentation of a server route.

Template Parameters
SettingsTypeThe settings used for this templated route.

Constructor & Destructor Documentation

◆ BaseRoute_()

template<typename SettingsType>
ofx::HTTP::BaseRoute_< SettingsType >::BaseRoute_ ( const SettingsType &  settings = SettingsType())

Create a BaseRoute.

Parameters
settingsThe settings to use for route configuration.

Member Function Documentation

◆ canHandleRequest()

template<typename SettingsType >
bool ofx::HTTP::BaseRoute_< SettingsType >::canHandleRequest ( const Poco::Net::HTTPServerRequest &  request,
bool  isSecurePort 
) const
overridevirtual

Determine if this route can handle the given request.

Parameters
requestThe incoming Poco::Net::HTTPServerRequest to be tested.
isSecurePorttrue iff the connection is SSL encrypted. Some implmenetations of this interface may choose to only handle requests on secure ports.
Returns
true iff the route can handle the given request.

Implements ofx::HTTP::AbstractRoute.

Reimplemented in ofx::HTTP::WebSocketRoute, and ofx::HTTP::SSERoute.

◆ createRequestHandler()

template<typename SettingsType >
Poco::Net::HTTPRequestHandler * ofx::HTTP::BaseRoute_< SettingsType >::createRequestHandler ( const Poco::Net::HTTPServerRequest &  request)
overridevirtual

Creates a new HTTPRequestHandler for the given request.

Before this is called, it is expected that the calling server has confirmed that this route is capable of handling the request by calling canHandleRequest().

Parameters
requestThe HTTPServerRequest to be passed to the handler.
Returns
An HTTPRequestHandler that will handle the request.
Note
Redeclared here for documentation puposes.

Implements ofx::HTTP::AbstractHTTPRequestHandlerFactory.

Reimplemented in ofx::HTTP::IPVideoRoute, ofx::HTTP::WebSocketRoute, ofx::HTTP::PostRoute, ofx::HTTP::SSERoute, and ofx::HTTP::FileSystemRoute.

◆ getServer()

template<typename SettingsType >
AbstractServer * ofx::HTTP::BaseRoute_< SettingsType >::getServer ( )
overridevirtual
Returns
a pointer to the server that owns this route.

Implements ofx::HTTP::AbstractRoute.

◆ handleRequest()

template<typename SettingsType >
void ofx::HTTP::BaseRoute_< SettingsType >::handleRequest ( ServerEventArgs evt)
overridevirtual

Handle the ServerEventArgs.

Parameters
evtThe server request event.

Implements ofx::HTTP::AbstractServerEventRequestHandler.

Reimplemented in ofx::HTTP::FileSystemRoute.

◆ routePathPattern()

template<typename SettingsType >
std::string ofx::HTTP::BaseRoute_< SettingsType >::routePathPattern ( ) const
overridevirtual

Get the route's regex path pattern.

The path pattern is used to match incoming server requests and allows requests to be routed to different routes based on their requested URI.

Returns
the regex path pattern.

Implements ofx::HTTP::AbstractRoute.

◆ setServer()

template<typename SettingsType >
void ofx::HTTP::BaseRoute_< SettingsType >::setServer ( AbstractServer server)
overridevirtual

Set the server that owns this route.

Parameters
serverA pointer to the server that owns this route.

Implements ofx::HTTP::AbstractRoute.

◆ settings()

template<typename SettingsType >
const SettingsType & ofx::HTTP::BaseRoute_< SettingsType >::settings ( ) const
Returns
the route's Settings.

◆ setup()

template<typename SettingsType>
void ofx::HTTP::BaseRoute_< SettingsType >::setup ( const SettingsType &  settings)
virtual

Setup the route with settings.

Parameters
settingsThe seetings to use for setup.

◆ stop()

template<typename SettingsType >
void ofx::HTTP::BaseRoute_< SettingsType >::stop ( )
overridevirtual

Stop any pending activity and close this route.

This method may block until the route is fully stopped.

Implements ofx::HTTP::AbstractRoute.

Reimplemented in ofx::HTTP::IPVideoRoute, ofx::HTTP::WebSocketRoute, and ofx::HTTP::SSERoute.


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