-
Notifications
You must be signed in to change notification settings - Fork 385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support RPC Transcoding for SRPCHttpServer #405
base: master
Are you sure you want to change the base?
Conversation
@@ -248,26 +248,49 @@ static inline void __set_host_by_uri(const ParsedURI *uri, bool is_ssl, | |||
} | |||
} | |||
|
|||
static inline bool __set_request_uri_by_uri(const ParsedURI *uri, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里写成const ParsedURI& uri吧。这个类我们好像一般用引用。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个主要是用到task->get_current_uri()作为参数,由于返回到是指针,所以相应的内部函数就把参数也写成指针了。
src/rpc_server.h
Outdated
const json_value_t *v; | ||
std::string str; | ||
|
||
val = json_value_parse(trans_coding); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个val没有destroy吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是的,漏了,已加。
tutorial/tutorial-20-trans_coding.cc
Outdated
SRPCHttpServer server; | ||
ExampleServiceImpl impl; | ||
|
||
server.add_service(&impl, "{ \"/test/echo\": \"Echo\"," |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里用可以写多行的字符串吧。
50a4c69
to
c87e6b7
Compare
src/rpc_server.h
Outdated
@@ -49,6 +50,7 @@ class RPCServer : public WFServer<typename RPCTYPE::REQ, | |||
RPCServer(const struct RPCServerParams *params); | |||
|
|||
int add_service(RPCService *service); | |||
int add_service(RPCService *service, const char *trans_coding); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里用const std::string& 吧。
补充关于trans_code转换的描述,如何将 request_uri通过path_map查找到service和method。 1. initializationserver.add_service(my_example_service, '{ "/echo_a" : "Echo", "/echo_b" : "Echo"}'); 这里会为server的path_map增加针对example_service的两个映射:
同时,为server的service_map增加一个查找service对象的映射(原有逻辑):
2. query
|
Mentioned in this issue : #404
TODO: