1
0

handler.h 541 B

12345678910111213141516171819
  1. #ifndef HV_PROTO_RPC_HANDLER_H_
  2. #define HV_PROTO_RPC_HANDLER_H_
  3. #include "../router.h"
  4. void error_response(protorpc::Response* res, int code, const std::string& message) {
  5. res->mutable_error()->set_code(code);
  6. res->mutable_error()->set_message(message);
  7. }
  8. void not_found(const protorpc::Request& req, protorpc::Response* res) {
  9. error_response(res, 404, "Not Found");
  10. }
  11. void bad_request(const protorpc::Request& req, protorpc::Response* res) {
  12. error_response(res, 400, "Bad Request");
  13. }
  14. #endif // HV_PROTO_RPC_HANDLER_H_