Hook up req->getParameter

This commit is contained in:
Alex Hultman
2018-10-05 00:10:43 +02:00
parent be0eb69597
commit 5e5d0de0e9
4 changed files with 29 additions and 21 deletions
+4 -3
View File
@@ -215,9 +215,10 @@ public:
void onGet(std::string pattern, std::function<void(uWS::HttpResponse<SSL> *, uWS::HttpRequest *)> handler) {
HttpContextData<SSL> *httpContextData = getSocketContextData();
httpContextData->router.add("get", pattern, [handler](typename HttpContextData<SSL>::UserData *user, auto &args) {
httpContextData->router.add("get", pattern, [handler](typename HttpContextData<SSL>::UserData *user, std::pair<int, std::string_view *> params) {
// todo: attach params to the req here!
user->httpRequest->setParameters(params);
handler(user->httpResponse, user->httpRequest);
});
@@ -226,7 +227,7 @@ public:
void onPost(std::string pattern, std::function<void(uWS::HttpResponse<SSL> *, uWS::HttpRequest *)> handler) {
HttpContextData<SSL> *httpContextData = getSocketContextData();
httpContextData->router.add("post", pattern, [handler](typename HttpContextData<SSL>::UserData *user, auto &args) {
httpContextData->router.add("post", pattern, [handler](typename HttpContextData<SSL>::UserData *user, std::pair<int, std::string_view *> params) {
handler(user->httpResponse, user->httpRequest);
});
}
@@ -234,7 +235,7 @@ public:
void onUnhandled(std::function<void(uWS::HttpResponse<SSL> *, uWS::HttpRequest *)> handler) {
HttpContextData<SSL> *httpContextData = getSocketContextData();
httpContextData->router.unhandled([handler](typename HttpContextData<SSL>::UserData *user, auto &args) {
httpContextData->router.unhandled([handler](typename HttpContextData<SSL>::UserData *user, std::pair<int, std::string_view *> params) {
handler(user->httpResponse, user->httpRequest);
});
}