25#include <boost/program_options/variables_map.hpp>
26#include <unordered_map>
29#include <seastar/http/matchrules.hh>
30#include <seastar/http/handlers.hh>
31#include <seastar/http/common.hh>
32#include <seastar/http/reply.hh>
33#include <seastar/util/modules.hh>
39SEASTAR_MODULE_EXPORT_BEGIN
54 url(
const sstring& path)
72struct path_description;
119 _rules[type][_rover++] = rule;
162 auto i = _map[type].find(
url);
163 return (i == _map[type].end()) ? nullptr : i->second;
183 sstring normalize_url(
const sstring&
url);
185 std::unordered_map<sstring, handler_base*> _map[NUM_OPERATION];
187 using rule_cookie = uint64_t;
189 rule_cookie _rover = 0;
190 std::map<rule_cookie, match_rule*> _rules[NUM_OPERATION];
194 using exception_handler_fun = std::function<std::unique_ptr<http::reply>(std::exception_ptr eptr)>;
195 using exception_handler_id = size_t;
197 std::map<exception_handler_id, exception_handler_fun> _exceptions;
198 exception_handler_id _exception_id = 0;
202 exception_handler_fun _general_handler;
210 auto current = _exception_id++;
211 _exceptions[current] = fun;
215 void remove_exception_handler(exception_handler_id
id) {
216 _exceptions.erase(
id);
219 std::unique_ptr<http::reply> exception_reply(std::exception_ptr eptr);
241 _rules[type][pos] = rule;
287 routes::rule_cookie _cookie;
304SEASTAR_MODULE_EXPORT_END
A representation of a possibly not-yet-computed value.
Definition: future.hh:1240
Definition: handlers.hh:42
Definition: routes.hh:259
handler_registration(routes &rs, handler_base &h, const sstring &url, operation_type op=GET)
Definition: matchrules.hh:42
routes & add(operation_type type, const url &url, handler_base *handler)
void add_alias(const path_description &old_path, const path_description &new_path)
add an alias to an already registered path. After registering a handler to a path,...
exception_handler_id register_exeption_handler(exception_handler_fun fun)
Definition: routes.hh:209
handler_base * get_exact_match(operation_type type, const sstring &url) const
Definition: routes.hh:161
future< std::unique_ptr< http::reply > > handle(const sstring &path, std::unique_ptr< http::request > req, std::unique_ptr< http::reply > rep)
rule_cookie add_cookie(match_rule *rule, operation_type type)
Definition: routes.hh:239
routes & put(operation_type type, const sstring &url, handler_base *handler)
match_rule * del_cookie(rule_cookie cookie, operation_type type)
handler_base * get_handler(operation_type type, const sstring &url, parameters ¶ms)
routes & add_default_handler(handler_base *handler)
routes & add(match_rule *rule, operation_type type=GET)
Definition: routes.hh:118
handler_base * drop(operation_type type, const sstring &url)
Definition: routes.hh:284
rule_registration(routes &rs, match_rule &rule, operation_type op=GET)
url(const sstring &path)
Definition: routes.hh:54
url & remainder(const sstring ¶m)
Definition: routes.hh:63
Seastar API namespace.
Definition: abort_on_ebadf.hh:26
Definition: json_path.hh:82