Debian Codegraph @

third-party/libhv-v1.3.3/examples/protorpc/handler/login.h

raw
1 #ifndef HV_PROTO_RPC_HANDLER_LOGIN_H_
2 #define HV_PROTO_RPC_HANDLER_LOGIN_H_
3
4 #include "../router.h"
5
6 #include "../generated/login.pb.h"
7
8 void login(const protorpc::Request& req, protorpc::Response* res) {
9 // params
10 if (req.params_size() == 0) {
11 return bad_request(req, res);
12 }
13 protorpc::LoginParam param;
14 if (!param.ParseFromString(req.params(0))) {
15 return bad_request(req, res);
16 }
17
18 // result
19 protorpc::LoginResult result;
20 result.set_user_id(123456);
21 result.set_token(param.username() + ":" + param.password());
22 res->set_result(result.SerializeAsString());
23 }
24
25 #endif // HV_PROTO_RPC_HANDLER_LOGIN_H_