Modify Interface to Query Parameters #65
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR changes the naming of parameter types to reflect a more common scheme. It also provides access to an iterator over the query parameters (
/?foo=1&bar=2
) to retrieve parameters with arbitrary names or multi-valued parameters.New Features
ResourceParameters
using an iterator:ResourceParameters::beginQueryParameters()
ResourceParameters::endQueryParameters()
ResourceParameters::getQueryParameterCount(bool unique)
bool getPathParameter(size_t const idx, std::string &value)
Breaking Changes
As changing the interface is a breaking change as such, this PR also changes the naming of request-related parameters to be more common and comprehensible. The "URL parameters" have become "path parameters", and "request parameters" are now "query parameters" like they're called in the RFC.
ResourceParameters::getRequestParameterInt()
std::atoi(str.c_str())
(see Parameters example for details)ResourceParameters::getUrlParameterInt()
std::atoi(str._cstr())
(see Parameters example for details)ResourceParameter::isRequestParameterSet()
toResourceParameter::isQueryParameterSet()
std::string ResourceParameter::getRequestParameter(std::string const &name)
bybool ResourceParameter::getQueryParameter(std::string const &name, std::string &val)
std::string ResourceParameter::getURLParameter(std::string const &name)
tostd::string ResourceParameter::getPathParameter(std::string const &name)
uint8_t HTTPNode::getUrlParamCount()
tosize_t HTTPNode::getPathParamCount()
References