CCF
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Protected Attributes | List of all members
ccf::RpcContextImpl Class Referenceabstract

#include <rpc_context_impl.h>

Inherits ccf::RpcContext.

Inherited by http::HttpRpcContext.

Public Member Functions

 RpcContextImpl (const std::shared_ptr< SessionContext > &s, HttpVersion v=HttpVersion::HTTP1)
 
std::shared_ptr< SessionContextget_session_context () const override
 
virtual void set_user_data (std::shared_ptr< void > data) override
 
virtual void * get_user_data () const override
 
void set_claims_digest (ccf::ClaimsDigest::Digest &&digest) override
 
virtual const ccf::PathParamsget_request_path_params () override
 
virtual const ccf::PathParamsget_decoded_request_path_params () override
 
HttpVersion get_http_version () const
 
virtual void set_error (ccf::http_status status, const std::string &code, std::string &&msg, const std::vector< nlohmann::json > &details={}) override
 Construct error response, formatted as JSON OData.
 
void set_error (ccf::ErrorDetails &&error) override
 Construct error response, formatted as JSON OData.
 
void set_response_json (const nlohmann::json &body, ccf::http_status status) override
 
virtual void set_tx_id (const ccf::TxID &tx_id)=0
 
virtual bool should_apply_writes () const =0
 
virtual void reset_response ()=0
 
virtual std::vector< uint8_t > serialise_response () const =0
 
virtual const std::vector< uint8_t > & get_serialised_request ()=0
 
- Public Member Functions inherited from ccf::RpcContext
virtual ~RpcContext ()=default
 
virtual const std::vector< uint8_t > & get_request_body () const =0
 
virtual const std::string & get_request_query () const =0
 
virtual const ccf::RESTVerbget_request_verb () const =0
 
virtual std::string get_request_path () const =0
 
virtual std::string get_method () const =0
 
virtual std::shared_ptr< ccf::http::HTTPResponderget_responder () const =0
 
virtual const http::HeaderMapget_request_headers () const =0
 Returns map of all headers found in the request.
 
virtual std::optional< std::string > get_request_header (const std::string_view &name) const =0
 
virtual const std::string & get_request_url () const =0
 
virtual ccf::FrameFormat frame_format () const =0
 
virtual void set_response_body (const std::vector< uint8_t > &body)=0
 Sets the main body or payload of the response.
 
virtual void set_response_body (std::vector< uint8_t > &&body)=0
 Sets the main body or payload of the response.
 
virtual void set_response_body (std::string &&body)=0
 Sets the main body or payload of the response.
 
virtual const std::vector< uint8_t > & get_response_body () const =0
 
virtual void set_response_status (int status)=0
 Sets initial status code summarising result of RPC.
 
virtual int get_response_status () const =0
 
virtual void set_response_header (const std::string_view &name, const std::string_view &value)=0
 
virtual void set_response_header (const std::string_view &name, size_t n)
 
virtual void set_response_header (const http::HeaderKeyValue &kv)
 
virtual void clear_response_headers ()=0
 
virtual void set_response_trailer (const std::string_view &name, const std::string_view &value)=0
 
virtual void set_response_trailer (const std::string_view &name, size_t n)
 
virtual void set_response_trailer (const http::HeaderKeyValue &kv)
 
virtual void set_apply_writes (bool apply)=0
 

Public Attributes

ccf::ClaimsDigest claims = ccf::empty_claims()
 
ccf::PathParams path_params = {}
 
ccf::PathParams decoded_path_params = {}
 
bool response_is_pending = false
 
bool terminate_session = false
 

Protected Attributes

std::shared_ptr< SessionContextsession
 
HttpVersion http_version
 
std::shared_ptr< void > user_data
 

Constructor & Destructor Documentation

◆ RpcContextImpl()

ccf::RpcContextImpl::RpcContextImpl ( const std::shared_ptr< SessionContext > &  s,
HttpVersion  v = HttpVersion::HTTP1 
)
inline

Member Function Documentation

◆ get_decoded_request_path_params()

virtual const ccf::PathParams & ccf::RpcContextImpl::get_decoded_request_path_params ( )
inlineoverridevirtual

Decodes the path before returning a map of all PathParams. For example, if the endpoint was installed at /foo/{name}/{age}, and for the request path /foo/bob%3A/42, this would return the map: {"name": "bob:", "age": "42"}

Implements ccf::RpcContext.

◆ get_http_version()

HttpVersion ccf::RpcContextImpl::get_http_version ( ) const
inline

◆ get_request_path_params()

virtual const ccf::PathParams & ccf::RpcContextImpl::get_request_path_params ( )
inlineoverridevirtual

Returns a map of all PathParams parsed out of the original query path. For instance if this endpoint was installed at /foo/{name}/{age}, and the request path /foo/bob/42, this would return the map: {"name": "bob", "age": "42"}

Implements ccf::RpcContext.

◆ get_serialised_request()

virtual const std::vector< uint8_t > & ccf::RpcContextImpl::get_serialised_request ( )
pure virtual

Implemented in http::HttpRpcContext.

◆ get_session_context()

std::shared_ptr< SessionContext > ccf::RpcContextImpl::get_session_context ( ) const
inlineoverridevirtual

Return information about the persistent session which this request was received on. Allows correlation between multiple requests coming from the same long-lived session.

Implements ccf::RpcContext.

◆ get_user_data()

virtual void * ccf::RpcContextImpl::get_user_data ( ) const
inlineoverridevirtual

Implements ccf::RpcContext.

◆ reset_response()

virtual void ccf::RpcContextImpl::reset_response ( )
pure virtual

Implemented in http::HttpRpcContext.

◆ serialise_response()

virtual std::vector< uint8_t > ccf::RpcContextImpl::serialise_response ( ) const
pure virtual

Implemented in http::HttpRpcContext.

◆ set_claims_digest()

void ccf::RpcContextImpl::set_claims_digest ( ccf::ClaimsDigest::Digest &&  digest)
inlineoverridevirtual

Sets the application claims digest associated with this transaction. This digest is used to construct the Merkle tree leaf representing this transaction. This allows a transaction to make specific, separately-revealable claims in each transaction, without being bound to the transaction serialisation format or what is stored in the KV. The digest will be included in receipts issued for that transaction.

Implements ccf::RpcContext.

◆ set_error() [1/2]

void ccf::RpcContextImpl::set_error ( ccf::ErrorDetails &&  error)
inlineoverridevirtual

Construct error response, formatted as JSON OData.

Implements ccf::RpcContext.

◆ set_error() [2/2]

virtual void ccf::RpcContextImpl::set_error ( ccf::http_status  status,
const std::string &  code,
std::string &&  msg,
const std::vector< nlohmann::json > &  details = {} 
)
inlineoverridevirtual

Construct error response, formatted as JSON OData.

Implements ccf::RpcContext.

◆ set_response_json()

void ccf::RpcContextImpl::set_response_json ( const nlohmann::json &  body,
ccf::http_status  status 
)
inlineoverridevirtual

Implements ccf::RpcContext.

◆ set_tx_id()

virtual void ccf::RpcContextImpl::set_tx_id ( const ccf::TxID tx_id)
pure virtual

Implemented in http::HttpRpcContext.

◆ set_user_data()

virtual void ccf::RpcContextImpl::set_user_data ( std::shared_ptr< void >  data)
inlineoverridevirtual

Implements ccf::RpcContext.

◆ should_apply_writes()

virtual bool ccf::RpcContextImpl::should_apply_writes ( ) const
pure virtual

Implemented in http::HttpRpcContext.

Member Data Documentation

◆ claims

ccf::ClaimsDigest ccf::RpcContextImpl::claims = ccf::empty_claims()

◆ decoded_path_params

ccf::PathParams ccf::RpcContextImpl::decoded_path_params = {}

◆ http_version

HttpVersion ccf::RpcContextImpl::http_version
protected

◆ path_params

ccf::PathParams ccf::RpcContextImpl::path_params = {}

◆ response_is_pending

bool ccf::RpcContextImpl::response_is_pending = false

◆ session

std::shared_ptr<SessionContext> ccf::RpcContextImpl::session
protected

◆ terminate_session

bool ccf::RpcContextImpl::terminate_session = false

◆ user_data

std::shared_ptr<void> ccf::RpcContextImpl::user_data
protected

The documentation for this class was generated from the following file: