25#ifndef MYSQLROUTER_REST_API_COMPONENT_INCLUDED
26#define MYSQLROUTER_REST_API_COMPONENT_INCLUDED
32#ifdef RAPIDJSON_NO_SIZETYPEDEFINE
36#include <rapidjson/document.h>
37#include <rapidjson/pointer.h>
38#include <rapidjson/prettywriter.h>
39#include <rapidjson/schema.h>
61 const std::vector<std::string> &path_matches) = 0;
76 : require_realm_(require_realm), allowed_methods_(allowed_methods) {}
78 bool try_handle_request(
80 const std::vector<std::string> &path_matches)
override;
84 const std::vector<std::string> &path_matches) = 0;
97 rapidjson::GenericDocument<rapidjson::UTF8<>, rapidjson::CrtAllocator>;
99 rapidjson::GenericValue<rapidjson::UTF8<>, JsonDocument::AllocatorType>;
101 rapidjson::GenericPointer<JsonValue, JsonDocument::AllocatorType>;
117 void init(std::shared_ptr<RestApi>
srv);
160 void add_path(
const std::string &
path,
161 std::unique_ptr<BaseRestApiHandler>
handler);
169 void remove_path(
const std::string &
path);
178 std::vector<std::pair<std::string, std::unique_ptr<BaseRestApiHandler>>>
192 std::unique_ptr<BaseRestApiHandler> endpoint)
static mysql_service_status_t init()
Component initialization.
Definition: audit_api_message_emit.cc:570
Definition: rest_api_component.h:45
BaseRestApiHandler()=default
virtual ~BaseRestApiHandler()
virtual bool try_handle_request(HttpRequest &req, const std::string &base_path, const std::vector< std::string > &path_matches)=0
try to handle the request.
BaseRestApiHandler & operator=(const BaseRestApiHandler &)=default
BaseRestApiHandler(const BaseRestApiHandler &)=default
BaseRestApiHandler & operator=(BaseRestApiHandler &&)=default
BaseRestApiHandler(BaseRestApiHandler &&)=default
a HTTP request and response.
Definition: http_request.h:452
Helper class to make unregistering paths in plugins easier.
Definition: rest_api_component.h:189
~RestApiComponentPath()
Definition: rest_api_component.h:197
RestApiComponent & rest_api_srv_
Definition: rest_api_component.h:206
RestApiComponentPath(RestApiComponent &rest_api_srv, std::string regex, std::unique_ptr< BaseRestApiHandler > endpoint)
Definition: rest_api_component.h:191
std::string regex_
Definition: rest_api_component.h:207
Definition: rest_api_component.h:92
RestApiComponent(RestApiComponent const &)=delete
void(*)(JsonDocument &spec_doc) SpecProcessor
processor for the RestAPI's spec.
Definition: rest_api_component.h:124
rapidjson::GenericValue< rapidjson::UTF8<>, JsonDocument::AllocatorType > JsonValue
Definition: rest_api_component.h:99
RestApiComponent()=default
std::weak_ptr< RestApi > srv_
Definition: rest_api_component.h:181
void add_path(const std::string &path, std::unique_ptr< BaseRestApiHandler > handler)
added handler for a path.
Definition: rest_api_component.cc:62
void operator=(RestApiComponent const &)=delete
std::mutex spec_mu_
Definition: rest_api_component.h:176
void remove_path(const std::string &path)
remove a path.
Definition: rest_api_component.cc:75
std::vector< std::pair< std::string, std::unique_ptr< BaseRestApiHandler > > > add_path_backlog_
Definition: rest_api_component.h:179
rapidjson::GenericDocument< rapidjson::UTF8<>, rapidjson::CrtAllocator > JsonDocument
Definition: rest_api_component.h:97
std::vector< SpecProcessor > spec_processors_
Definition: rest_api_component.h:177
rapidjson::GenericPointer< JsonValue, JsonDocument::AllocatorType > JsonPointer
Definition: rest_api_component.h:101
handler for REST API calls.
Definition: rest_api_component.h:72
virtual bool on_handle_request(HttpRequest &req, const std::string &base_path, const std::vector< std::string > &path_matches)=0
HttpMethod::Bitset allowed_methods_
Definition: rest_api_component.h:89
RestApiHandler(const std::string &require_realm, HttpMethod::Bitset allowed_methods)
Definition: rest_api_component.h:74
std::string require_realm_
Definition: rest_api_component.h:87
Definition: rest_api_plugin.h:34
The handler class is the interface for dynamically loadable storage engines.
Definition: handler.h:4548
Define rapidjson::SizeType to be std::size_t.
static char * path
Definition: mysqldump.cc:148
std::bitset< Pos::_LAST+1 > Bitset
Definition: http_request.h:267
Definition: srv0dynamic_procedures.h:47
Definition: varlen_sort.h:174
#define REST_API_EXPORT
Definition: rest_api_export.h:15