MySQL 9.6.0
Source Code Documentation
handler.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2021, 2025, 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 ROUTER_SRC_REST_MRS_SRC_MRS_REST_HANDLER_H_
27#define ROUTER_SRC_REST_MRS_SRC_MRS_REST_HANDLER_H_
28
29#include <optional>
30#include <string>
31#include <vector>
32
33#include "helper/media_type.h"
34#include "http/base/uri.h"
39
40namespace mrs {
41namespace rest {
42
44 const std::optional<std::string> &options);
45
47 public:
51
52 public:
53 Handler(const Protocol protocol, const std::string &url_host,
54 const std::vector<UriPathMatcher> &rest_path_matcher,
55 const std::optional<std::string> &options,
56 interface::AuthorizeManager *auth_manager);
57
58 ~Handler() override;
59
60 void initialize(const Configuration &configuration) override;
61
62 const std::string &get_url_host() const override;
63 const std::string &get_protocol() const override;
64 bool may_check_access() const override;
65 void authorization(RequestContext *ctxt) override;
66 bool request_begin(RequestContext *ctxt) override;
67 void request_end(RequestContext *ctxt) override;
68 /**
69 * Error handler.
70 *
71 * Method that allows customization of error handling.
72 *
73 * @returns true in case when the handler send response to the client
74 * @returns false in case when the default handler should send a response to
75 * the client
76 */
77 bool request_error(RequestContext *ctxt, const http::Error &e) override;
78
79 const interface::Options &get_options() const override;
80
82
83 uint32_t check_privileges(
84 const std::vector<database::entry::AuthPrivilege> &privileges,
85 const UniversalId &service_id, const std::string &service_path,
86 const UniversalId &schema_id, const std::string &schema_path,
87 const UniversalId &db_object_id, const std::string &db_object_path);
88
89 protected:
91 const std::string url_host_;
92 std::vector<UriPathMatcher> rest_path_matcher_;
93 std::vector<void *> handler_id_;
95 const std::string protocol_;
96 std::shared_ptr<Configuration> configuration_;
97
100
101 const std::string &empty_path() const;
102};
103
104} // namespace rest
105} // namespace mrs
106
107#endif // ROUTER_SRC_REST_MRS_SRC_MRS_REST_HANDLER_H_
Definition: protocol.h:33
Definition: uri.h:40
Definition: error.h:37
Definition: authorize_manager.h:58
Definition: rest_handler.h:77
Definition: rest_handler.h:141
Definition: handler.h:46
bool log_level_is_debug_
Definition: handler.h:98
std::vector< UriPathMatcher > rest_path_matcher_
Definition: handler.h:92
bool may_check_access() const override
Definition: handler.cc:303
const std::string protocol_
Definition: handler.h:95
void initialize(const Configuration &configuration) override
Definition: handler.cc:255
bool log_level_is_info_
Definition: handler.h:99
bool request_begin(RequestContext *ctxt) override
Definition: handler.cc:280
bool request_error(RequestContext *ctxt, const http::Error &e) override
Error handler.
Definition: handler.cc:284
interface::AuthorizeManager * authorization_manager_
Definition: handler.h:94
void authorization(RequestContext *ctxt) override
Definition: handler.cc:297
const std::string & empty_path() const
Definition: handler.cc:305
~Handler() override
Definition: handler.cc:232
std::shared_ptr< Configuration > configuration_
Definition: handler.h:96
void request_end(RequestContext *ctxt) override
Definition: handler.cc:282
const interface::Options & get_options() const override
Definition: handler.cc:288
uint32_t check_privileges(const std::vector< database::entry::AuthPrivilege > &privileges, const UniversalId &service_id, const std::string &service_path, const UniversalId &schema_id, const std::string &schema_path, const UniversalId &db_object_id, const std::string &db_object_path)
Definition: handler.cc:45
Handler(const Protocol protocol, const std::string &url_host, const std::vector< UriPathMatcher > &rest_path_matcher, const std::optional< std::string > &options, interface::AuthorizeManager *auth_manager)
Definition: handler.cc:199
const std::string url_host_
Definition: handler.h:91
std::vector< void * > handler_id_
Definition: handler.h:93
void throw_unauthorize_when_check_auth_fails(RequestContext *)
Definition: handler.cc:290
interface::Options options_
Definition: handler.h:90
const std::string & get_protocol() const override
Definition: handler.cc:301
const std::string & get_url_host() const override
Definition: handler.cc:299
Request::Uri Uri
Definition: request.cc:36
Protocol
Definition: protocol.h:35
mrs::interface::Options parse_json_options(const std::optional< std::string > &options)
Definition: handler.cc:192
Definition: authorize_manager.h:48
mrs::database::entry::UniversalId UniversalId
Definition: universal_id.h:33
Definition: options.cc:57
required string configuration
Definition: replication_asynchronous_connection_failover.proto:49
Definition: uri_path_matcher.h:40
Definition: request_context.h:47