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>
63 const std::vector<std::string> &path_matches) = 0;
78 : require_realm_(require_realm), allowed_methods_(allowed_methods) {}
80 bool try_handle_request(
82 const std::vector<std::string> &path_matches)
override;
86 const std::vector<std::string> &path_matches) = 0;
99 rapidjson::GenericDocument<rapidjson::UTF8<>, rapidjson::CrtAllocator>;
101 rapidjson::GenericValue<rapidjson::UTF8<>, JsonDocument::AllocatorType>;
103 rapidjson::GenericPointer<JsonValue, JsonDocument::AllocatorType>;
119 void init(std::shared_ptr<RestApi>
srv);
162 void add_path(
const std::string &
path,
163 std::unique_ptr<BaseRestApiHandler>
handler);
171 void remove_path(
const std::string &
path);
180 std::vector<std::pair<std::string, std::unique_ptr<BaseRestApiHandler>>>
194 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:47
BaseRestApiHandler()=default
virtual ~BaseRestApiHandler()
virtual bool try_handle_request(http::base::Request &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
Helper class to make unregistering paths in plugins easier.
Definition: rest_api_component.h:191
~RestApiComponentPath()
Definition: rest_api_component.h:199
RestApiComponent & rest_api_srv_
Definition: rest_api_component.h:208
RestApiComponentPath(RestApiComponent &rest_api_srv, std::string regex, std::unique_ptr< BaseRestApiHandler > endpoint)
Definition: rest_api_component.h:193
std::string regex_
Definition: rest_api_component.h:209
Definition: rest_api_component.h:94
RestApiComponent(RestApiComponent const &)=delete
void(*)(JsonDocument &spec_doc) SpecProcessor
processor for the RestAPI's spec.
Definition: rest_api_component.h:126
rapidjson::GenericValue< rapidjson::UTF8<>, JsonDocument::AllocatorType > JsonValue
Definition: rest_api_component.h:101
RestApiComponent()=default
std::weak_ptr< RestApi > srv_
Definition: rest_api_component.h:183
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:178
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:181
rapidjson::GenericDocument< rapidjson::UTF8<>, rapidjson::CrtAllocator > JsonDocument
Definition: rest_api_component.h:99
std::vector< SpecProcessor > spec_processors_
Definition: rest_api_component.h:179
rapidjson::GenericPointer< JsonValue, JsonDocument::AllocatorType > JsonPointer
Definition: rest_api_component.h:103
handler for REST API calls.
Definition: rest_api_component.h:74
HttpMethod::Bitset allowed_methods_
Definition: rest_api_component.h:91
RestApiHandler(const std::string &require_realm, HttpMethod::Bitset allowed_methods)
Definition: rest_api_component.h:76
std::string require_realm_
Definition: rest_api_component.h:89
virtual bool on_handle_request(http::base::Request &req, const std::string &base_path, const std::vector< std::string > &path_matches)=0
Definition: rest_api_plugin.h:35
The handler class is the interface for dynamically loadable storage engines.
Definition: handler.h:4573
Define rapidjson::SizeType to be std::size_t.
static char * path
Definition: mysqldump.cc:149
std::bitset< Pos::_LAST+1 > Bitset
Definition: method.h:57
Definition: srv0dynamic_procedures.h:48
Definition: gcs_xcom_synode.h:64
#define REST_API_EXPORT
Definition: rest_api_export.h:15