26#ifndef MYSQLROUTER_REST_API_COMPONENT_INCLUDED
27#define MYSQLROUTER_REST_API_COMPONENT_INCLUDED
33#ifdef RAPIDJSON_NO_SIZETYPEDEFINE
37#include <rapidjson/document.h>
38#include <rapidjson/pointer.h>
39#include <rapidjson/prettywriter.h>
40#include <rapidjson/schema.h>
62 const std::vector<std::string> &path_matches) = 0;
77 : require_realm_(require_realm), allowed_methods_(allowed_methods) {}
79 bool try_handle_request(
81 const std::vector<std::string> &path_matches)
override;
85 const std::vector<std::string> &path_matches) = 0;
98 rapidjson::GenericDocument<rapidjson::UTF8<>, rapidjson::CrtAllocator>;
100 rapidjson::GenericValue<rapidjson::UTF8<>, JsonDocument::AllocatorType>;
102 rapidjson::GenericPointer<JsonValue, JsonDocument::AllocatorType>;
118 void init(std::shared_ptr<RestApi>
srv);
161 void add_path(
const std::string &
path,
162 std::unique_ptr<BaseRestApiHandler>
handler);
170 void remove_path(
const std::string &
path);
179 std::vector<std::pair<std::string, std::unique_ptr<BaseRestApiHandler>>>
193 std::unique_ptr<BaseRestApiHandler> endpoint)
static mysql_service_status_t init()
Component initialization.
Definition: audit_api_message_emit.cc:571
Definition: rest_api_component.h:46
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:453
Helper class to make unregistering paths in plugins easier.
Definition: rest_api_component.h:190
~RestApiComponentPath()
Definition: rest_api_component.h:198
RestApiComponent & rest_api_srv_
Definition: rest_api_component.h:207
RestApiComponentPath(RestApiComponent &rest_api_srv, std::string regex, std::unique_ptr< BaseRestApiHandler > endpoint)
Definition: rest_api_component.h:192
std::string regex_
Definition: rest_api_component.h:208
Definition: rest_api_component.h:93
RestApiComponent(RestApiComponent const &)=delete
void(*)(JsonDocument &spec_doc) SpecProcessor
processor for the RestAPI's spec.
Definition: rest_api_component.h:125
rapidjson::GenericValue< rapidjson::UTF8<>, JsonDocument::AllocatorType > JsonValue
Definition: rest_api_component.h:100
RestApiComponent()=default
std::weak_ptr< RestApi > srv_
Definition: rest_api_component.h:182
void add_path(const std::string &path, std::unique_ptr< BaseRestApiHandler > handler)
added handler for a path.
Definition: rest_api_component.cc:63
void operator=(RestApiComponent const &)=delete
std::mutex spec_mu_
Definition: rest_api_component.h:177
void remove_path(const std::string &path)
remove a path.
Definition: rest_api_component.cc:76
std::vector< std::pair< std::string, std::unique_ptr< BaseRestApiHandler > > > add_path_backlog_
Definition: rest_api_component.h:180
rapidjson::GenericDocument< rapidjson::UTF8<>, rapidjson::CrtAllocator > JsonDocument
Definition: rest_api_component.h:98
std::vector< SpecProcessor > spec_processors_
Definition: rest_api_component.h:178
rapidjson::GenericPointer< JsonValue, JsonDocument::AllocatorType > JsonPointer
Definition: rest_api_component.h:102
handler for REST API calls.
Definition: rest_api_component.h:73
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:90
RestApiHandler(const std::string &require_realm, HttpMethod::Bitset allowed_methods)
Definition: rest_api_component.h:75
std::string require_realm_
Definition: rest_api_component.h:88
Definition: rest_api_plugin.h:35
The handler class is the interface for dynamically loadable storage engines.
Definition: handler.h:4414
Define rapidjson::SizeType to be std::size_t.
static char * path
Definition: mysqldump.cc:137
std::bitset< Pos::_LAST+1 > Bitset
Definition: http_request.h:268
Definition: srv0dynamic_procedures.h:48
Definition: gcs_xcom_synode.h:64
#define REST_API_EXPORT
Definition: rest_api_export.h:15