RAVENNAKIT
Loading...
Searching...
No Matches
rav::HttpRouter< HandlerType > Class Template Reference

A simple HTTP router that matches HTTP requests to handlers based on the method and path. More...

#include <http_router.hpp>

Public Member Functions

void insert (const boost::beast::http::verb method, const std::string_view pattern, HandlerType handler)
 Inserts a new route into the router.
HandlerType * match (const boost::beast::http::verb method, const std::string_view path, PathMatcher::Parameters *parameters)
 Matches the given method and path to a handler.

Detailed Description

template<typename HandlerType>
class rav::HttpRouter< HandlerType >

A simple HTTP router that matches HTTP requests to handlers based on the method and path.

Template Parameters
HandlerTypeThe type of the handler function.

Definition at line 44 of file http_router.hpp.

Member Function Documentation

◆ insert()

template<typename HandlerType>
void rav::HttpRouter< HandlerType >::insert ( const boost::beast::http::verb method,
const std::string_view pattern,
HandlerType handler )
inline

Inserts a new route into the router.

If a handler already exists for the given method and pattern, it will be updated.

Parameters
methodThe HTTP method to match (e.g., GET, POST).
patternThe path pattern to match.
handlerThe handler function to call when the route is matched.

Definition at line 53 of file http_router.hpp.

◆ match()

template<typename HandlerType>
HandlerType * rav::HttpRouter< HandlerType >::match ( const boost::beast::http::verb method,
const std::string_view path,
PathMatcher::Parameters * parameters )
inline

Matches the given method and path to a handler.

If a matching route is found, the handler is returned.

Parameters
methodThe HTTP method to match (e.g., GET, POST).
pathThe path to match.
parametersThe parameters to fill with the extracted values from the path.
Returns
A pointer to the matching handler, or nullptr if no match is found.

Definition at line 76 of file http_router.hpp.


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