#include <api_handler.h>
|
typedef std::function< HANDLER_RESULT< ApiResponse >(ApiRequest &)> | REQUEST_HANDLER |
| A handler for outer messages (envelopes) that will unpack to inner messages and call a specific handler function.
|
|
|
template<class RequestType , class ResponseType , class HandlerType > |
void | registerHandler (HANDLER_RESULT< ResponseType >(HandlerType::*aHandler)(RequestType &, const HANDLER_CONTEXT &)) |
| Registers an API command handler for the given message types.
|
|
|
template<typename MessageType > |
bool | tryUnpack (ApiRequest &aRequest, ApiResponse &aReply, MessageType &aDest) |
|
Definition at line 54 of file api_handler.h.
◆ REQUEST_HANDLER
A handler for outer messages (envelopes) that will unpack to inner messages and call a specific handler function.
- See also
- registerHandler.
Definition at line 74 of file api_handler.h.
◆ API_HANDLER()
API_HANDLER::API_HANDLER |
( |
| ) |
|
|
inline |
◆ ~API_HANDLER()
virtual API_HANDLER::~API_HANDLER |
( |
| ) |
|
|
inlinevirtual |
◆ Handle()
API_RESULT API_HANDLER::Handle |
( |
ApiRequest & |
aMsg | ) |
|
Attempt to handle the given API request, if a handler exists in this class for the message.
- Parameters
-
aMsg | is a request to attempt to handle |
- Returns
- a response to send to the client, or an appropriate error
Definition at line 30 of file api_handler.cpp.
References m_handlers.
◆ registerHandler()
template<class RequestType , class ResponseType , class HandlerType >
Registers an API command handler for the given message types.
When an API request matching the given type comes in, the handler will be called and its response will be packed into an envelope for sending back to the API client.
If the given message does not unpack into the request type, an envelope is returned with status AS_BAD_REQUEST, which probably indicates corruption in the message.
- Template Parameters
-
RequestType | is a protobuf message type containing a command |
ResponseType | is a protobuf message type containing a command response |
HandlerType | is the implied type of the API_HANDLER subclass |
- Parameters
-
aHandler | is the handler function for the given request and response types |
Definition at line 91 of file api_handler.h.
References HANDLER_CONTEXT::ClientName.
◆ tryUnpack()
template<typename MessageType >
bool API_HANDLER::tryUnpack |
( |
ApiRequest & |
aRequest, |
|
|
ApiResponse & |
aReply, |
|
|
MessageType & |
aDest |
|
) |
| |
|
inlineprivate |
◆ m_defaultCommitMessage
const wxString API_HANDLER::m_defaultCommitMessage = _( "Modification from API" ) |
|
staticprotected |
◆ m_handlers
Maps type name (without the URL prefix) to a handler method.
Definition at line 129 of file api_handler.h.
Referenced by Handle().
The documentation for this class was generated from the following files: