Add the getParameter() method into the HttpRequest class
This commit is contained in:
parent
89cac562cf
commit
6d16877e7b
|
@ -85,6 +85,9 @@ class HttpRequest
|
|||
/// Get parameters of the request.
|
||||
virtual const std::unordered_map<std::string, std::string> &getParameters() const = 0;
|
||||
|
||||
/// Get a parameter identified by the @param key
|
||||
virtual const std::string &getParameter(const std::string &key, const std::string &defaultVal = std::string()) const = 0;
|
||||
|
||||
/// Return the remote IP address and port
|
||||
virtual const trantor::InetAddress &peerAddr() const = 0;
|
||||
|
||||
|
|
|
@ -157,10 +157,18 @@ class HttpRequestImpl : public HttpRequest
|
|||
_path = path;
|
||||
}
|
||||
|
||||
const std::unordered_map<std::string, std::string> &getParameters() const override
|
||||
virtual const std::unordered_map<std::string, std::string> &getParameters() const override
|
||||
{
|
||||
return _parameters;
|
||||
}
|
||||
|
||||
virtual const std::string &getParameter(const std::string &key, const std::string &defaultVal = std::string()) const override
|
||||
{
|
||||
auto iter = _parameters.find(key);
|
||||
if (iter != _parameters.end())
|
||||
return iter->second;
|
||||
return defaultVal;
|
||||
}
|
||||
|
||||
const std::string &path() const override
|
||||
{
|
||||
|
|
|
@ -39,7 +39,7 @@ const std::vector<HttpFile> &MultiPartParser::getFiles()
|
|||
const std::map<std::string, std::string> &MultiPartParser::getParameters() const
|
||||
{
|
||||
return _parameters;
|
||||
};
|
||||
}
|
||||
|
||||
int MultiPartParser::parse(const HttpRequestPtr &req)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue