26#ifndef MYSQLROUTER_HTTP_SERVER_PLUGIN_INCLUDED
27#define MYSQLROUTER_HTTP_SERVER_PLUGIN_INCLUDED
44 void append(
const std::string &url_regex_str,
45 std::unique_ptr<BaseRequestHandler> cb);
46 void remove(
const std::string &url_regex_str);
61 std::unique_ptr<BaseRequestHandler>
handler;
139 virtual void start(
size_t max_threads);
142 void add_route(
const std::string &url_regex,
143 std::unique_ptr<BaseRequestHandler> cb);
Main event registration and dispatch engine
Definition: http_common.h:115
Http server build on top of EventBase.
Definition: http_request.h:525
void set_allowed_http_methods(const HttpMethod::Bitset methods)
Set allowed methods for client request.
Definition: http_common.cc:252
Definition: http_server_plugin.h:42
void route_default(HttpRequest &req)
Definition: http_server_plugin.cc:98
void require_realm(const std::string &realm)
Definition: http_server_plugin.h:55
void clear_default_route()
Definition: http_server_plugin.cc:123
std::string require_realm_
Definition: http_server_plugin.h:66
std::unique_ptr< BaseRequestHandler > default_route_
Definition: http_server_plugin.h:65
void route(HttpRequest req)
Definition: http_server_plugin.cc:128
std::mutex route_mtx_
Definition: http_server_plugin.h:68
void remove(const std::string &url_regex_str)
Definition: http_server_plugin.cc:86
std::vector< RouterData > request_handlers_
Definition: http_server_plugin.h:63
void append(const std::string &url_regex_str, std::unique_ptr< BaseRequestHandler > cb)
request router
Definition: http_server_plugin.cc:78
void set_default_route(std::unique_ptr< BaseRequestHandler > cb)
Definition: http_server_plugin.cc:117
base class of all http request handler threads
Definition: http_server_plugin.h:83
EventHttp event_http_
Definition: http_server_plugin.h:119
HttpRequestThread(HttpRequestThread &&object)
Definition: http_server_plugin.h:94
void wait_and_dispatch()
Definition: http_server_plugin.cc:185
void initialization_finished()
Definition: http_server_plugin.cc:228
void break_dispatching()
Definition: http_server_plugin.cc:197
void accept_socket()
Definition: http_server_plugin.cc:170
bool is_initalized() const
Definition: http_server_plugin.cc:219
void set_request_router(HttpRequestRouter &router)
Definition: http_server_plugin.cc:176
void wait_until_ready()
Definition: http_server_plugin.cc:208
static void on_event_loop_ready(native_handle_type, short, void *)
Definition: http_server_plugin.cc:212
WaitableMonitor< bool > initialized_
Definition: http_server_plugin.h:121
native_handle_type get_socket_fd()
Definition: http_server_plugin.h:102
EventBase event_base_
Definition: http_server_plugin.h:118
native_handle_type accept_fd_
Definition: http_server_plugin.h:120
HttpRequestThread()
Definition: http_server_plugin.h:85
EventBaseSocket native_handle_type
Definition: http_server_plugin.h:100
a HTTP request and response.
Definition: http_request.h:453
Definition: http_server_plugin.h:124
std::string address_
Definition: http_server_plugin.h:150
HttpServer(const HttpServer &)=delete
net::io_context io_ctx_
Definition: http_server_plugin.h:154
virtual ~HttpServer()
Definition: http_server_plugin.h:137
HttpServer & operator=(HttpServer &&)=delete
void remove_route(const std::string &url_regex)
Definition: http_server_plugin.cc:417
HttpRequestRouter request_router_
Definition: http_server_plugin.h:152
HttpServer(const char *address, uint16_t port)
Definition: http_server_plugin.h:126
HttpServer & operator=(const HttpServer &)=delete
std::vector< HttpRequestThread > thread_contexts_
Definition: http_server_plugin.h:149
void join_all()
Definition: http_server_plugin.cc:322
void stop()
Definition: http_server_plugin.cc:363
HttpServer(HttpServer &&)=delete
uint16_t port_
Definition: http_server_plugin.h:151
net::ip::tcp::acceptor listen_sock_
Definition: http_server_plugin.h:155
std::vector< std::thread > sys_threads_
Definition: http_server_plugin.h:157
void add_route(const std::string &url_regex, std::unique_ptr< BaseRequestHandler > cb)
Definition: http_server_plugin.cc:407
virtual void start(size_t max_threads)
Definition: http_server_plugin.cc:332
HttpRequestRouter & request_router()
Definition: http_server_plugin.h:146
Monitor can be waited for.
Definition: monitor.h:62
Definition: socket.h:1412
Definition: io_context.h:61
evutil_socket_t EventBaseSocket
Definition: http_common.h:99
const int kEventBaseInvalidSocket
Definition: http_common.h:107
std::bitset< Pos::_LAST+1 > Bitset
Definition: http_request.h:268
Definition: gcs_xcom_synode.h:64
std::set< Key, Compare, ut::allocator< Key > > set
Specialization of set which uses ut_allocator.
Definition: ut0new.h:2882
required uint64 port
Definition: replication_asynchronous_connection_failover.proto:33
Definition: http_server_plugin.h:58
std::regex url_regex
Definition: http_server_plugin.h:60
std::string url_regex_str
Definition: http_server_plugin.h:59
std::unique_ptr< BaseRequestHandler > handler
Definition: http_server_plugin.h:61