Yet Another HTTP Library
yahttp
|
#include <router.hpp>
Public Member Functions | |
void | map (const std::string &method, const std::string &url, THandlerFunction handler, const std::string &name) |
bool | route (Request *req, THandlerFunction &handler) |
void | printRoutes (std::ostream &os) |
std::pair< std::string, std::string > | urlFor (const std::string &name, const strstr_map_t &arguments) |
Static Public Member Functions | |
static void | Map (const std::string &method, const std::string &url, THandlerFunction handler, const std::string &name="") |
static void | Get (const std::string &url, THandlerFunction handler, const std::string &name="") |
static void | Post (const std::string &url, THandlerFunction handler, const std::string &name="") |
static void | Put (const std::string &url, THandlerFunction handler, const std::string &name="") |
static void | Patch (const std::string &url, THandlerFunction handler, const std::string &name="") |
static void | Delete (const std::string &url, THandlerFunction handler, const std::string &name="") |
static void | Any (const std::string &url, THandlerFunction handler, const std::string &name="") |
static bool | Route (Request *req, THandlerFunction &handler) |
static void | PrintRoutes (std::ostream &os) |
static std::pair< std::string, std::string > | URLFor (const std::string &name, const strstr_map_t &arguments) |
static const TRouteList & | GetRoutes () |
Public Attributes | |
TRouteList | routes |
Private Member Functions | |
Router () | |
Static Private Attributes | |
static Router | router |
Implements simple router.
This class implements a router for masked urls. The URL mask syntax is as of follows
/<masked>/url<number>/<hi>.<format>
You can use <param> to denote that everything will be matched and consumed into the parameter, including slash (/). Use <> to denote that URL is consumed but not stored. Note that only path is matched, scheme, host and url parameters are ignored.
|
inlineprivate |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
void YaHTTP::Router::map | ( | const std::string & | method, |
const std::string & | url, | ||
THandlerFunction | handler, | ||
const std::string & | name | ||
) |
|
inlinestatic |
Map an URL. If method is left empty, it will match any method. Name is also optional, but needed if you want to find it for making URLs
|
inlinestatic |
|
inlinestatic |
void YaHTTP::Router::printRoutes | ( | std::ostream & | os | ) |
|
inlinestatic |
|
inlinestatic |
bool YaHTTP::Router::route | ( | Request * | req, |
THandlerFunction & | handler | ||
) |
|
inlinestatic |
std::pair< std::string, std::string > YaHTTP::Router::urlFor | ( | const std::string & | name, |
const strstr_map_t & | arguments | ||
) |
|
inlinestatic |
|
staticprivate |
TRouteList YaHTTP::Router::routes |