Skip to content

Modify Interface to Query Parameters #65

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

Merged
merged 1 commit into from
Dec 24, 2019

Conversation

fhessel
Copy link
Owner

@fhessel fhessel commented Dec 5, 2019

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

  • Provide access to all query parameters in ResourceParameters using an iterator:
    • Added ResourceParameters::beginQueryParameters()
    • Added ResourceParameters::endQueryParameters()
  • Allow retrieving the count of query parameters:
    • Added ResourceParameters::getQueryParameterCount(bool unique)
  • Allow checking and retrieving path parameters safely:
    • Added 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.

  • Drop ResourceParameters::getRequestParameterInt()
    • Alternative: use std::atoi(str.c_str()) (see Parameters example for details)
  • Drop ResourceParameters::getUrlParameterInt()
    • Alternative: use std::atoi(str._cstr()) (see Parameters example for details)
  • Rename ResourceParameter::isRequestParameterSet() to ResourceParameter::isQueryParameterSet()
  • Replace std::string ResourceParameter::getRequestParameter(std::string const &name) by bool ResourceParameter::getQueryParameter(std::string const &name, std::string &val)
  • Rename std::string ResourceParameter::getURLParameter(std::string const &name) to std::string ResourceParameter::getPathParameter(std::string const &name)
  • Rename uint8_t HTTPNode::getUrlParamCount() to size_t HTTPNode::getPathParamCount()

References

@fhessel fhessel merged commit c4312fe into master Dec 24, 2019
@fhessel fhessel deleted the feature/request-param-parsing branch December 24, 2019 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant