CCF
|
#include <endpoint.h>
Inherits ccf::endpoints::EndpointDefinition.
Inherited by ccf::endpoints::PathTemplatedEndpoint, and ccf::js::CustomJSEndpoint.
Classes | |
struct | Installer |
Public Types | |
using | SchemaBuilderFn = std::function< void(nlohmann::json &, const Endpoint &)> |
Public Member Functions | |
Endpoint & | set_openapi_description (const std::string &description) |
Endpoint & | set_openapi_summary (const std::string &summary) |
Endpoint & | set_openapi_deprecated (bool is_deprecated) |
Endpoint & | set_openapi_deprecated_replaced (const std::string &deprecation_version, const std::string &replacement) |
Endpoint & | set_openapi_hidden (bool hidden) |
Endpoint & | set_params_schema (const nlohmann::json &j) |
Endpoint & | set_result_schema (const nlohmann::json &j, std::optional< http_status > status=std::nullopt) |
template<typename In , typename Out > | |
Endpoint & | set_auto_schema (std::optional< http_status > status=std::nullopt) |
template<typename T > | |
Endpoint & | set_auto_schema (std::optional< http_status > status=std::nullopt) |
template<typename T > | |
Endpoint & | add_query_parameter (const std::string ¶m_name, QueryParamPresence presence=RequiredParameter) |
Endpoint & | set_forwarding_required (ForwardingRequired fr) |
Endpoint & | set_redirection_strategy (RedirectionStrategy rs) |
void | install () |
![]() | |
virtual | ~EndpointDefinition ()=default |
Public Attributes | |
EndpointFunction | func = {} |
LocallyCommittedEndpointFunction | locally_committed_func = {} |
Installer * | installer |
std::vector< SchemaBuilderFn > | schema_builders = {} |
bool | openapi_hidden = false |
http_status | success_status = HTTP_STATUS_OK |
nlohmann::json | params_schema = nullptr |
nlohmann::json | result_schema = nullptr |
std::optional< std::string > | openapi_summary = std::nullopt |
std::optional< std::string > | openapi_description = std::nullopt |
std::optional< bool > | openapi_deprecated = std::nullopt |
![]() | |
EndpointKey | dispatch |
URI | full_uri_path |
Full URI path to endpoint, including method prefix. | |
EndpointProperties | properties |
AuthnPolicies | authn_policies |
An Endpoint represents a user-defined resource that can be invoked by authorised users via HTTP requests, over TLS. An Endpoint is accessible at a specific verb and URI, e.g. POST /app/accounts or GET /app/records.
Endpoints can read from and mutate the state of the replicated key-value store.
A CCF application is a collection of Endpoints recorded in the application's EndpointRegistry.
using ccf::endpoints::Endpoint::SchemaBuilderFn = std::function<void(nlohmann::json&, const Endpoint&)> |
|
inline |
Add OpenAPI documentation for a query parameter which can be passed to this endpoint.
T | Type with appropriate ds::json specialisations to generate a JSON schema description |
param_name | Name to be used for the query parameter to this Endpoint |
presence | Enum value indicating whether this parameter is required or optional |
void ccf::endpoints::Endpoint::install | ( | ) |
|
inline |
Sets the schema that the request and response bodies should comply with. These are used to populate the generated OpenAPI document, but do not introduce any constraints on the actual types that are parsed or produced by the handling functor.
embed:rst:leading-asterisk * .. note:: * See ``DECLARE_JSON_`` serialisation macros for serialising * user-defined data structures. *
In | Request body JSON-serialisable data structure |
Out | Response body JSON-serialisable data structure |
status | Response status code |
|
inline |
Sets schemas for request and response bodies using typedefs within T.
embed:rst:leading-asterisk * .. note:: * ``T`` data structure should contain two nested ``In`` and ``Out`` * structures for request parameters and response format, respectively. *
T | Type containing In and Out typedefs with JSON-schema description specialisations |
status | Request response status code |
Endpoint & ccf::endpoints::Endpoint::set_forwarding_required | ( | endpoints::ForwardingRequired | fr | ) |
Endpoint & ccf::endpoints::Endpoint::set_openapi_deprecated | ( | bool | is_deprecated | ) |
Set the endpoint as deprecated.
Endpoint & ccf::endpoints::Endpoint::set_openapi_deprecated_replaced | ( | const std::string & | deprecation_version, |
const std::string & | replacement | ||
) |
Set the endpoint as deprecated and overwrites the description to include deprecation version and point to a replacement endpoint.
Endpoint & ccf::endpoints::Endpoint::set_openapi_description | ( | const std::string & | description | ) |
Set the OpenAPI description for the endpoint.
Endpoint & ccf::endpoints::Endpoint::set_openapi_hidden | ( | bool | hidden | ) |
Whether the endpoint should be omitted from the OpenAPI document.
Endpoint & ccf::endpoints::Endpoint::set_openapi_summary | ( | const std::string & | summary | ) |
Set the OpenAPI summary for the endpoint.
Endpoint & ccf::endpoints::Endpoint::set_params_schema | ( | const nlohmann::json & | j | ) |
Sets the JSON schema that the request parameters must comply with.
j | Request parameters JSON schema |
Endpoint & ccf::endpoints::Endpoint::set_redirection_strategy | ( | RedirectionStrategy | rs | ) |
Endpoint & ccf::endpoints::Endpoint::set_result_schema | ( | const nlohmann::json & | j, |
std::optional< http_status > | status = std::nullopt |
||
) |
Sets the JSON schema that the request response must comply with.
j | Request response JSON schema |
status | Request response status code |
EndpointFunction ccf::endpoints::Endpoint::func = {} |
Installer* ccf::endpoints::Endpoint::installer |
LocallyCommittedEndpointFunction ccf::endpoints::Endpoint::locally_committed_func = {} |
std::optional<bool> ccf::endpoints::Endpoint::openapi_deprecated = std::nullopt |
std::optional<std::string> ccf::endpoints::Endpoint::openapi_description = std::nullopt |
bool ccf::endpoints::Endpoint::openapi_hidden = false |
std::optional<std::string> ccf::endpoints::Endpoint::openapi_summary = std::nullopt |
nlohmann::json ccf::endpoints::Endpoint::params_schema = nullptr |
nlohmann::json ccf::endpoints::Endpoint::result_schema = nullptr |
std::vector<SchemaBuilderFn> ccf::endpoints::Endpoint::schema_builders = {} |
http_status ccf::endpoints::Endpoint::success_status = HTTP_STATUS_OK |