4#include <unordered_map>
20 std::unordered_map<std::string, std::string>
named;
22 std::optional<std::string>
getParam(
const std::string& name)
const {
23 auto it =
named.find(name);
24 if (it !=
named.end())
return it->second;
56 const std::vector<std::string>& params = {})
std::function< bool(HttpRequest &, HttpResponse &, const RouteMatch &)> Middleware
Function signature for middleware components.
std::function< void(HttpRequest &, HttpResponse &, const RouteMatch &)> RouteHandler
Type definitions for route handlers and middleware.
std::function< void(HttpRequest &, HttpResponse &, const RouteMatch &)> RouteHandler
Function signature for HTTP route handlers.
Forward declaration for potential routing needs.
Represents an HTTP response object.
Represents a match of a route against an incoming HTTP request.
std::vector< std::string > ordered
std::unordered_map< std::string, std::string > named
std::optional< std::string > getParam(const std::string &name) const
Represents a single HTTP route.
std::vector< std::string > paramNames
Route(const std::string &m, const std::string &p, RouteHandler h, bool dynamic=false, bool auth=false, const std::vector< std::string > ¶ms={})