HttpRouter.hpp

This File On Github
Ask A Question

API: latest
module: oatpp
#include "oatpp/web/server/HttpRouter.hpp"

HttpRouter

HttpRouter is responsible for routing http requests by method and path-pattern.

namespace oatpp { namespace web { namespace server { 
  class HttpRouter : public oatpp::base::Countable {}
}}}

Typedefs

Type Name Summary
oatpp::data::share::StringKeyLabel StringKeyLabel Convenience typedef for oatpp::data::share::StringKeyLabel.
oatpp::web::url::mapping::Router<HttpRequestHandler> BranchRouter oatpp::web::url::mapping::Router of oatpp::web::server::HttpRequestHandler.
std::unordered_map<StringKeyLabel, std::shared_ptr<BranchRouter>> BranchMap Http method to HttpRouter::BranchRouter map. Meaning that for each http method like ["GET", "POST", ...] there is a separate HttpRouter::BranchRouter.

Methods

Return Type Name Summary
[none] HttpRouter Constructor.
std::shared_ptr<HttpRouter> createShared Create shared HttpRouter.
void route Route URL to Handler by method, and pathPattern.
BranchRouter::Route getRoute Resolve http method and path to oatpp::web::url::mapping::Router::Route
void logRouterMappings Print out all router mapping.

HttpRouter::StringKeyLabel

Convenience typedef for oatpp::data::share::StringKeyLabel.

typedef oatpp::data::share::StringKeyLabel StringKeyLabel

HttpRouter::BranchRouter

oatpp::web::url::mapping::Router of oatpp::web::server::HttpRequestHandler.

typedef oatpp::web::url::mapping::Router<HttpRequestHandler> BranchRouter

HttpRouter::BranchMap

Http method to HttpRouter::BranchRouter map. Meaning that for each http method like ["GET", "POST", ...] there is a separate HttpRouter::BranchRouter.

typedef std::unordered_map<StringKeyLabel, std::shared_ptr<BranchRouter>> BranchMap

HttpRouter::HttpRouter

Constructor.

HttpRouter()

HttpRouter::createShared

Create shared HttpRouter.

  • @return - std::shared_ptr to HttpRouter.

static std::shared_ptr<HttpRouter> createShared()

HttpRouter::route

Route URL to Handler by method, and pathPattern.

  • @param method - http method like ["GET", "POST", etc.].
  • @param pathPattern - url path pattern. ex.: "/path/to/resource/with/{param1}/{param2}".
  • @param handler - oatpp::web::server::HttpRequestHandler.

void route(const oatpp::String& method, const oatpp::String& pathPattern, const std::shared_ptr<HttpRequestHandler>& handler)

HttpRouter::getRoute

Resolve http method and path to oatpp::web::url::mapping::Router::Route

BranchRouter::Route getRoute(const StringKeyLabel& method, const StringKeyLabel& path)

HttpRouter::logRouterMappings

Print out all router mapping.

void logRouterMappings()