-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
路由的占位符解析和查询参数的解析覆盖问题 #573
Comments
为了使用简单,所以不管是url里的还是query_string里的参数都是解析后保持在query_params里,通过GetParam获取,建议使用不同的参数名区分下。 |
好的,不过个人认为还是做个区分比较好,后面加个getRoute的接口可以考虑吗? |
为了前向兼容性暂不考虑,如果是你个人fork后修改,我推荐命名GetUrlParam和GetQueryParam |
好的,如果是为前向兼容考虑的话,个人认为可以给路由和查询参数新建两个接口,其值也分别新建成员变量存储,旧的GetParam接口和query_params声明不推荐使用 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
router.cpp示例中:
libhv/examples/httpd/router.cpp
Lines 131 to 134 in 0325f2d
这里路由占位符的解析是在Handler::restful中调用了HttpContext的param,即HttpRequest的GetParam:
libhv/examples/httpd/handler.cpp
Lines 171 to 179 in 0325f2d
这个方法是查询参数的解析,这样合在一起会导致这里占位符的解析覆盖了查询参数的解析,如对于/api/test/{str},会导致 GET http://ip:port/api/test/xxx?str=yyy 后,服务器获取查询参数param("str")时,xxx会覆盖yyy
The text was updated successfully, but these errors were encountered: