router.h 892 B

123456789101112131415161718192021222324
  1. #ifndef HV_PROTO_RPC_ROUTER_H_
  2. #define HV_PROTO_RPC_ROUTER_H_
  3. #include "generated/base.pb.h"
  4. typedef void (*protorpc_handler)(const protorpc::Request& req, protorpc::Response* res);
  5. typedef struct {
  6. const char* method;
  7. protorpc_handler handler;
  8. } protorpc_router;
  9. void error_response(protorpc::Response* res, int code, const std::string& message);
  10. void not_found(const protorpc::Request& req, protorpc::Response* res);
  11. void bad_request(const protorpc::Request& req, protorpc::Response* res);
  12. void calc_add(const protorpc::Request& req, protorpc::Response* res);
  13. void calc_sub(const protorpc::Request& req, protorpc::Response* res);
  14. void calc_mul(const protorpc::Request& req, protorpc::Response* res);
  15. void calc_div(const protorpc::Request& req, protorpc::Response* res);
  16. void login(const protorpc::Request& req, protorpc::Response* res);
  17. #endif // HV_PROTO_RPC_ROUTER_H_