KiCad PCB EDA Suite
|
#include <api_handler_common.h>
Public Member Functions | |
API_HANDLER_COMMON () | |
API_RESULT | Handle (ApiRequest &aMsg) |
Attempt to handle the given API request, if a handler exists in this class for the message. | |
Protected Types | |
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. | |
Protected Member Functions | |
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. | |
Protected Attributes | |
std::map< std::string, REQUEST_HANDLER > | m_handlers |
Maps type name (without the URL prefix) to a handler method. | |
Static Protected Attributes | |
static const wxString | m_defaultCommitMessage = _( "Modification from API" ) |
Private Member Functions | |
HANDLER_RESULT< commands::GetVersionResponse > | handleGetVersion (commands::GetVersion &aMsg, const HANDLER_CONTEXT &aCtx) |
HANDLER_RESULT< commands::NetClassesResponse > | handleGetNetClasses (commands::GetNetClasses &aMsg, const HANDLER_CONTEXT &aCtx) |
HANDLER_RESULT< Empty > | handlePing (commands::Ping &aMsg, const HANDLER_CONTEXT &aCtx) |
template<typename MessageType > | |
bool | tryUnpack (ApiRequest &aRequest, ApiResponse &aReply, MessageType &aDest) |
Definition at line 34 of file api_handler_common.h.
|
protectedinherited |
A handler for outer messages (envelopes) that will unpack to inner messages and call a specific handler function.
Definition at line 74 of file api_handler.h.
API_HANDLER_COMMON::API_HANDLER_COMMON | ( | ) |
Definition at line 37 of file api_handler_common.cpp.
References handleGetNetClasses(), handleGetVersion(), and handlePing().
|
inherited |
Attempt to handle the given API request, if a handler exists in this class for the message.
aMsg | is a request to attempt to handle |
Definition at line 30 of file api_handler.cpp.
References API_HANDLER::m_handlers.
|
private |
Definition at line 62 of file api_handler_common.cpp.
References PROJECT::GetProjectFile(), PGM_BASE::GetSettingsManager(), PROJECT_FILE::m_NetSettings, name, Pgm(), and SETTINGS_MANAGER::Prj().
Referenced by API_HANDLER_COMMON().
|
private |
Definition at line 46 of file api_handler_common.cpp.
References GetBuildVersion(), and GetMajorMinorPatchTuple().
Referenced by API_HANDLER_COMMON().
|
private |
Definition at line 79 of file api_handler_common.cpp.
Referenced by API_HANDLER_COMMON().
|
inlineprotectedinherited |
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.
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 |
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.
|
inlineprivateinherited |
Definition at line 136 of file api_handler.h.
|
staticprotectedinherited |
Definition at line 131 of file api_handler.h.
Referenced by API_HANDLER_EDITOR::pushCurrentCommit().
|
protectedinherited |
Maps type name (without the URL prefix) to a handler method.
Definition at line 129 of file api_handler.h.
Referenced by API_HANDLER::Handle().