Add query parameters to RestService::Handle()

This commit is contained in:
Adam Gu
2018-04-23 13:22:59 +08:00
parent f921256a33
commit bcfb1e4c92
5 changed files with 17 additions and 2 deletions
+4
View File
@@ -84,10 +84,14 @@ HttpStatus::Enum RestRequestHandler::HandleSession(HttpSessionPtr session) {
return HttpStatus::kBadRequest;
}
// TODO: Only for GET?
Url::Query query = Url::SplitQuery(url.query());
// TODO: Error handling.
std::string content;
service->Handle(session->request().method(),
sub_matches,
query,
session->request().content(),
&content);
+8 -2
View File
@@ -1,6 +1,7 @@
#ifndef WEBCC_REST_SERVICE_H_
#define WEBCC_REST_SERVICE_H_
#include <map>
#include <memory>
#include <string>
#include <vector>
@@ -16,10 +17,15 @@ public:
}
// Handle REST request, output the response.
// Both the request and response parameters should be JSON.
// TODO: Query parameters.
// \param http_method GET, POST, etc.
// \param url_sub_matches The regex sub-matches in the URL,
// usually resource ID.
// \param query Query parameters in the URL, key value pairs.
// \param request_content Request JSON.
// \param response_content Output response JSON.
virtual bool Handle(const std::string& http_method,
const std::vector<std::string>& url_sub_matches,
const std::map<std::string, std::string>& query,
const std::string& request_content,
std::string* response_content) = 0;
};