1#ifndef NEFORCE_NETWORK_HTTP_HTTP_ROUTER_HPP__
2#define NEFORCE_NETWORK_HTTP_HTTP_ROUTER_HPP__
14NEFORCE_BEGIN_NAMESPACE__
88 bool is_regex =
false;
94 http_handler_t not_found_handler_;
95 http_handler_t method_not_allowed_handler_;
96 exception_handler_t exception_handler_;
105 void setup_default_handlers();
189 method_not_allowed_handler_ = _NEFORCE
move(handler);
236NEFORCE_END_NAMESPACE__
void post_delete(const string &path, http_handler_t handler)
同时注册POST和DELETE
bool strict_routing
是否严格匹配尾部斜杠
NEFORCE_NODISCARD size_t route_count() const noexcept
获取路由总数
void del(const string &path, http_handler_t handler)
DELETE请求
void get(const string &path, http_handler_t handler)
GET请求
void options(const string &path, http_handler_t handler)
OPTIONS请求
void trace(const string &path, http_handler_t handler)
TRACE请求
void set_not_found_handler(http_handler_t handler)
设置404处理器
void post(const string &path, http_handler_t handler)
POST请求
NEFORCE_NODISCARD bool has_route(const http_method &method, const string &path) const
检查是否存在指定路由
function< void(http_request &, http_response &)> http_handler_t
HTTP处理器类型
function< void(http_request &, http_response &, const exception &)> exception_handler_t
异常处理器类型
void set_exception_handler(exception_handler_t handler)
设置异常处理器
void head(const string &path, http_handler_t handler)
HEAD请求
http_response handle_request(http_request &request)
处理HTTP请求
bool case_sensitive
是否大小写敏感
void connect(const string &path, http_handler_t handler)
CONNECT请求
void clear_routes() noexcept
清空所有路由
void get_post(const string &path, http_handler_t handler)
同时注册GET和POST
void set_method_not_allowed_handler(http_handler_t handler)
设置405处理器
void put(const string &path, http_handler_t handler)
PUT请求
void all(const string &path, http_handler_t handler)
注册所有HTTP方法
void route(const http_method &method, const string &path, const http_handler_t &handler)
通用路由注册
void patch(const string &path, http_handler_t handler)
PATCH请求
http_filter_chain & middleware_chain() noexcept
获取中间件链引用
void use(unique_ptr< http_filter > middleware)
添加中间件
http_server_response http_response
HTTP响应类型别名
http_server_request http_request
HTTP请求类型别名
constexpr Iterator2 move(Iterator1 first, Iterator1 last, Iterator2 result) noexcept(noexcept(inner::__move_aux(first, last, result)))
移动范围元素