|  | MySQL 9.5.0
    Source Code Documentation | 
#include <chrono>#include <map>#include <string>#include <rapidjson/document.h>#include "http/base/request.h"#include "mysql/harness/utility/string.h"Go to the source code of this file.
| Functions | |
| void | send_rfc7807_error (http::base::Request &req, HttpStatusCode::key_type status_code, const std::map< std::string, std::string > &fields) | 
| send a JsonProblem HTTP response.  More... | |
| bool | ensure_http_method (http::base::Request &req, HttpMethod::Bitset allowed_methods) | 
| ensure HTTP method is allowed.  More... | |
| bool | ensure_auth (http::base::Request &req, const std::string require_realm) | 
| ensure request is authenticated.  More... | |
| bool | ensure_no_params (http::base::Request &req) | 
| ensure request has no parameters.  More... | |
| void | send_rfc7807_not_found_error (http::base::Request &req) | 
| send a JsonProblem "Not Found" error.  More... | |
| bool | ensure_modified_since (http::base::Request &req, time_t last_modified) | 
| ensure resource has modified since client received it.  More... | |
| void | send_json_document (http::base::Request &req, HttpStatusCode::key_type status_code, const rapidjson::Document &json_doc) | 
| send json document as HTTP response.  More... | |
| template<class Encoding , class AllocatorType > | |
| rapidjson::GenericValue< Encoding, AllocatorType > | json_value_from_timepoint (std::chrono::time_point< std::chrono::system_clock > tp, AllocatorType &allocator) | 
| format a timepoint as json-value (date-time format).  More... | |
| bool ensure_auth | ( | http::base::Request & | req, | 
| const std::string | require_realm | ||
| ) | 
ensure request is authenticated.
sends HTTP-response with status 401 if authentication was not successful.
| true | if request is authenticaticated | 
| false | if authentication was not successful and HTTP response has been sent | 
| bool ensure_http_method | ( | http::base::Request & | req, | 
| HttpMethod::Bitset | allowed_methods | ||
| ) | 
ensure HTTP method is allowed.
sends HTTP-response with status 405 if method is not allowed and sets Allow HTTP header.
| true | if HTTP method is allowed | 
| false | if HTTP is not allowed and HTTP response has been sent | 
| bool ensure_modified_since | ( | http::base::Request & | req, | 
| time_t | last_modified | ||
| ) | 
ensure resource has modified since client received it.
sends HTTP-response with status 304 if client has a newer version that
| true | if resource is modified since client received it. | 
| false | if client has the same resource and HTTP response has been sent | 
| bool ensure_no_params | ( | http::base::Request & | req | ) | 
ensure request has no parameters.
sends HTTP-response with status 400 if request contained a query string.
| true | if request did not contain a query-string | 
| false | if request contained a query-string and HTTP response has been sent | 
| rapidjson::GenericValue< Encoding, AllocatorType > json_value_from_timepoint | ( | std::chrono::time_point< std::chrono::system_clock > | tp, | 
| AllocatorType & | allocator | ||
| ) | 
format a timepoint as json-value (date-time format).
| void send_json_document | ( | http::base::Request & | req, | 
| HttpStatusCode::key_type | status_code, | ||
| const rapidjson::Document & | json_doc | ||
| ) | 
send json document as HTTP response.
Content-Type must be sent before the function is called.
| req | HttpRequest object to send error-msg | 
| status_code | HTTP Status code of the problem message | 
| json_doc | json document to send as response | 
| void send_rfc7807_error | ( | http::base::Request & | req, | 
| HttpStatusCode::key_type | status_code, | ||
| const std::map< std::string, std::string > & | fields | ||
| ) | 
send a JsonProblem HTTP response.
RFC 7807 defines application/problem+json:
| req | HttpRequest object to send error-msg | 
| status_code | HTTP Status code of the problem message | 
| fields | fields on the problem message | 
| void send_rfc7807_not_found_error | ( | http::base::Request & | req | ) | 
send a JsonProblem "Not Found" error.
| req | HttpRequest object to send error-msg |