24using kiapi::common::ApiRequest, kiapi::common::ApiResponse, kiapi::common::ApiResponseStatus;
32 ApiResponseStatus status;
34 if( !aMsg.has_message() )
36 status.set_status( ApiStatusCode::AS_BAD_REQUEST );
37 status.set_error_message(
"request has no inner message" );
38 return tl::unexpected( status );
43 if( !google::protobuf::Any::ParseAnyTypeUrl( aMsg.message().type_url(), &typeName ) )
45 status.set_status( ApiStatusCode::AS_BAD_REQUEST );
46 status.set_error_message(
"could not parse inner message type" );
47 return tl::unexpected( status );
55 return handler( aMsg );
58 status.set_status( ApiStatusCode::AS_UNHANDLED );
60 return tl::unexpected( status );
tl::expected< ApiResponse, ApiResponseStatus > API_RESULT
static const wxString m_defaultCommitMessage
std::map< std::string, REQUEST_HANDLER > m_handlers
Maps type name (without the URL prefix) to a handler method.
std::function< HANDLER_RESULT< ApiResponse >(ApiRequest &)> REQUEST_HANDLER
A handler for outer messages (envelopes) that will unpack to inner messages and call a specific handl...
API_RESULT Handle(ApiRequest &aMsg)
Attempt to handle the given API request, if a handler exists in this class for the message.