Exposing Router::addRoute

parent c2067dec
......@@ -225,6 +225,7 @@ public:
void patch(const std::string& resource, Route::Handler handler);
void del(const std::string& resource, Route::Handler handler);
void options(const std::string& resource, Route::Handler handler);
void addRoute(Http::Method method, const std::string& resource, Route::Handler handler);
void removeRoute(Http::Method method, const std::string& resource);
void addCustomHandler(Route::Handler handler);
......@@ -243,9 +244,6 @@ public:
private:
void addRoute(Http::Method method, const std::string& resource,
Route::Handler handler);
std::unordered_map<Http::Method, SegmentTreeNode> routes;
std::vector<Route::Handler> customHandlers;
......
......@@ -449,8 +449,7 @@ Router::route(const Http::Request& req, Http::ResponseWriter response) {
return Route::Status::NotFound;
}
void Router::addRoute(Http::Method method,
const std::string& resource, Route::Handler handler) {
void Router::addRoute(Http::Method method, const std::string& resource, Route::Handler handler) {
if (resource.empty()) throw std::runtime_error("Invalid zero-length URL.");
auto& r = routes[method];
const auto sanitized = SegmentTreeNode::sanitizeResource(resource);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment