Skip to content
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

Refactor query string processing #468

Open
mmd-osm opened this issue Feb 27, 2025 · 0 comments
Open

Refactor query string processing #468

mmd-osm opened this issue Feb 27, 2025 · 0 comments

Comments

@mmd-osm
Copy link
Collaborator

mmd-osm commented Feb 27, 2025

Query string parsing is a bit of a mess right now. Parsing should be done only once, and results stored in an std::map in "struct request". This needs to work both for fcgi, as well as unit tests.

Example 1:

  string decoded = http::urldecode(get_query_string(req));
  const auto params = http::parse_params(decoded);
  auto itr =
    std::find_if(params.begin(), params.end(),
        [](const pair<string, string> &p) { return p.first == "bbox"; });
        

Example 2:

std::vector<id_version> parse_id_list_params(const request &req,
                                             std::string_view param_name) {

  std::string decoded = http::urldecode(get_query_string(req));
  const auto params = http::parse_params(decoded);

  auto itr = std::find_if(params.begin(), params.end(), [&param_name](auto &x) {
    return x.first == param_name;
  });

  if (itr == params.end())
    return {};

  const std::string &str = itr->second;
            

(there are a few others as well).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant