MySQL 8.4.2
Source Code Documentation
http_server_context.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2021, 2024, Oracle and/or its affiliates.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License, version 2.0,
6 as published by the Free Software Foundation.
7
8 This program is designed to work with certain software (including
9 but not limited to OpenSSL) that is licensed under separate terms,
10 as designated in a particular file or component or in included license
11 documentation. The authors of MySQL hereby grant you an additional
12 permission to link the program and your derivative works with the
13 separately licensed software that they have either included with
14 the program or referenced in the documentation.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24*/
25
26#ifndef MYSQLROUTER_SERVER_CONTEXT_INCLUDED
27#define MYSQLROUTER_SERVER_CONTEXT_INCLUDED
28
29#include <cassert>
30#include <list>
31#include <memory>
32#include <thread>
33#include <type_traits>
34#include <vector>
35
37
38#include "http/server/bind.h"
39#include "http/server/server.h"
40#include "http_request_router.h"
42
43namespace http {
44
46 public:
47 using IoThreads = std::list<IoThread>;
48
49 public:
50 HttpServerContext(net::io_context *context, IoThreads *io_threads,
51 TlsServerContext &&tls_context, const std::string &host,
52 const uint16_t port);
53
54 HttpServerContext(net::io_context *context, IoThreads *io_threads,
55 const std::string &host, const uint16_t port);
56
57 void start();
58 void stop();
59 void join_all();
60
61 void add_route(const std::string &url_regex,
62 std::unique_ptr<http::base::RequestHandler> cb);
63 void remove_route(const std::string &url_regex);
64 void remove_route(const void *handler_id);
65
66 bool is_ssl_configured();
67
68 HttpRequestRouter &request_router();
69
70 private:
73 std::string host_;
74 uint16_t port_;
75 bool ssl_{false};
76 server::Bind bind{context_, host_, port_};
77 server::Server http;
78
79 private:
81};
82
83} // namespace http
84
85#endif // MYSQLROUTER_SERVER_CONTEXT_INCLUDED
Definition: http_request_router.h:42
TLS Context for the server side.
Definition: tls_server_context.h:51
Definition: http_server_context.h:45
std::list< IoThread > IoThreads
Definition: http_server_context.h:47
TlsServerContext tls_context_
Definition: http_server_context.h:72
net::io_context * context_
Definition: http_server_context.h:71
HttpRequestRouter request_handler_
Definition: http_server_context.h:80
server::Server http
Definition: http_server_context.h:77
uint16_t port_
Definition: http_server_context.h:74
std::string host_
Definition: http_server_context.h:73
Definition: io_context.h:61
static void start(mysql_harness::PluginFuncEnv *env)
Definition: http_auth_backend_plugin.cc:180
#define HTTP_SERVER_LIB_EXPORT
Definition: http_server_lib_export.h:15
const char * host
Definition: mysqladmin.cc:65
Definition: connection.h:56
stdx::expected< void, error_type > bind(native_handle_type native_handle, const struct sockaddr *addr, size_t addr_len)
wrap bind() in a portable way.
Definition: socket.h:339
required uint64 port
Definition: replication_asynchronous_connection_failover.proto:33