-
Notifications
You must be signed in to change notification settings - Fork 58
Conversation
return error_s::make(ERR_INVALID_PARAMETERS, std::string("repeat parameters")); | ||
ret.query_args.emplace(arg_vals[0], arg_vals[1]); | ||
for (const std::string &arg_val : method_arg_val) { | ||
size_t sep = arg_val.find_first_of('='); |
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.
感觉这种split类的操作在我们的项目中有好几种实现方式
这里是可以抽象出来, split出多个元素(1个,2个或多个可能是有不同的处理逻辑)
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.
是的,之前引入 pprof 的时候还引入了 brpc 的 string_splitter
,这个是相对 boost::split
性能更好的一种 split 写法,减少了内存拷贝,后面可以主推这种。但是在这里我们因为逻辑简单,杀鸡就不用牛刀了把。
@@ -47,7 +47,7 @@ class recent_start_time_http_service : public http_service | |||
std::placeholders::_2)); | |||
} | |||
|
|||
std::string path() const override { return "startTime"; } | |||
std::string path() const override { return "recentStartTime"; } |
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.
这里我觉得还是path作为一个http_service的成员变量比较好, 由基类返回就行了
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.
现在的写法在可靠性上问题不大,理解你的想法是每个 service 要写一个 path 函数比较麻烦?这个交给后面的重构做把。
{"http://127.0.0.1:34601?query1=value1", ERR_OK, {{"query1", "value1"}}}, | ||
{"http://127.0.0.1:34601?=", ERR_OK, {{"", ""}}}, | ||
{"http://127.0.0.1:34601?", ERR_OK, {}}, | ||
|
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.
这些空行隐藏了什么特殊意义吗?
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.
没有,因为参数比较多,避免看花眼
The major improvements are the followings:
table_printer
, so that http result on/recentStartTime
are more readable.the old result is:
the new result is:
?arg=true
, for example:Now, the url can be simplified to: