8 #include <unordered_set> 9 #include <unordered_map> 13 #include <boost/asio/ip/tcp.hpp> 45 typedef std::unordered_map<std::string, std::string>
matches;
54 const boost::asio::ip::tcp::socket&
socket;
88 Route(
const char*
path, router_handler fn);
97 std::optional<matches> match(
const char*
uri)
const;
112 std::vector<std::string> keys;
114 const char* component_re =
":([^\\/]+)?";
116 const char* replace_re =
"(?:([^\\/]+?))";
147 bool is_method_used(
boost::beast::
http::
verb method) const noexcept;
156 std::unordered_set<
int> avail_methods;
159 typedef
std::vector<
Route> handler_map_t;
161 handler_map_t get_handlers;
163 handler_map_t head_handlers;
165 handler_map_t post_handlers;
167 handler_map_t put_handlers;
169 handler_map_t delete_handlers;
171 handler_map_t options_handlers;
173 handler_map_t trace_handlers;
176 handler_map_t* map_method(
boost::beast::
http::
verb method) noexcept;
178 const handler_map_t* map_method(
boost::beast::
http::
verb method) const noexcept;
dynamic_response & response
boost::beast response into which handler writes stuff
Definition: router.hpp:58
Definition: router.hpp:52
Definition: async_result.hpp:20
Definition: type_traits.hpp:25
The DELETE method deletes the specified resource.
verb
Definition: verb.hpp:26
Definition: beast_common.hpp:6
Method
Definition: router.hpp:21
const boost::asio::ip::tcp::socket & socket
asio's socket can give access to useful information such as local/remote endpoint.
Definition: router.hpp:54
const dynamic_request & request
boost::beast request
Definition: router.hpp:56
Definition: router.hpp:43
std::function< void(Context &&)> router_handler
Type of route's handler.
Definition: router.hpp:69
const matches matches
regex matches
Definition: router.hpp:60
boost::string_ref string_view
The type of string view used by the library.
Definition: string.hpp:36
router_handler callback
Route's handler.
Definition: router.hpp:106
boost::asio::ip::tcp tcp
Definition: router.cpp:6
std::unordered_map< std::string, std::string > matches
Definition: router.hpp:45
Definition: router.hpp:74