Fawkes API  Fawkes Development Version
fawkes::WebUrlManager Class Reference

Manage URL mappings. More...

#include <>>

Public Types

typedef std::function< WebReply *(const WebRequest *)> Handler
 Function type for handling requests. More...
 

Public Member Functions

 WebUrlManager ()
 Constructor. More...
 
 ~WebUrlManager ()
 Destructor. More...
 
void add_handler (WebRequest::Method method, const std::string &path, Handler handler)
 Add a request processor. More...
 
void remove_handler (WebRequest::Method method, const std::string &path)
 Remove a request processor. More...
 
void add_handler (WebRequest::Method method, const std::string &path, Handler handler, int weight)
 Add a request processor with weight. More...
 

Detailed Description

Manage URL mappings.

This class maps (base) URLs to web request processors which handle all requests for the given URL.

Author
Tim Niemueller

Definition at line 39 of file url_manager.h.

Member Typedef Documentation

◆ Handler

typedef std::function<WebReply *(const WebRequest *)> fawkes::WebUrlManager::Handler

Function type for handling requests.

Definition at line 45 of file url_manager.h.

Constructor & Destructor Documentation

◆ WebUrlManager()

fawkes::WebUrlManager::WebUrlManager ( )

Constructor.

Definition at line 37 of file url_manager.cpp.

◆ ~WebUrlManager()

fawkes::WebUrlManager::~WebUrlManager ( )

Destructor.

Definition at line 42 of file url_manager.cpp.

Member Function Documentation

◆ add_handler() [1/2]

void fawkes::WebUrlManager::add_handler ( WebRequest::Method  method,
const std::string &  path,
Handler  handler 
)

Add a request processor.

Parameters
methodHTTP method to register for
pathpath pattern to register for, may contain {var}, {var*}, and {var+} elements
handlerhandler function
Exceptions
Exceptionthrown if a processor has already been registered for the given URL prefix.

Definition at line 54 of file url_manager.cpp.

Referenced by MetricsThread::init(), WebviewThread::init(), XmlRpcThread::init(), WebviewRESTRequestProcessor::WebviewRESTRequestProcessor(), and WebviewStaticRequestProcessor::WebviewStaticRequestProcessor().

◆ add_handler() [2/2]

void fawkes::WebUrlManager::add_handler ( WebRequest::Method  method,
const std::string &  path,
Handler  handler,
int  weight 
)

Add a request processor with weight.

This one should mostly be necessary to implement "catch-all" handlers.

Parameters
methodHTTP method to register for
pathpath pattern to register for, may contain {var}, {var*}, and {var+} elements
handlerhandler function
weightthe higher the weight the later the handler will be tried.
Exceptions
Exceptionthrown if a processor has already been registered for the given URL prefix.

Definition at line 70 of file url_manager.cpp.

◆ remove_handler()

void fawkes::WebUrlManager::remove_handler ( WebRequest::Method  method,
const std::string &  path 
)

Remove a request processor.

Parameters
methodHTTP method to unregister from
pathpath pattern to unregister from

Definition at line 84 of file url_manager.cpp.

Referenced by MetricsThread::finalize(), WebviewThread::finalize(), XmlRpcThread::finalize(), WebviewRESTRequestProcessor::~WebviewRESTRequestProcessor(), and WebviewStaticRequestProcessor::~WebviewStaticRequestProcessor().


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