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

How to obtain anchor params in request? #2027

Open
sergey-chernikov opened this issue Jan 23, 2025 · 2 comments
Open

How to obtain anchor params in request? #2027

sergey-chernikov opened this issue Jan 23, 2025 · 2 comments

Comments

@sergey-chernikov
Copy link

I mean this kind of stuff:
http://example.com/#param1=value1&param2=value2...
neither of params, path_params or target contain them

Thank you in advance.

@yhirose
Copy link
Owner

yhirose commented Jan 24, 2025

@sergey-chernikov thanks for the question, but I don't really understand what you are asking... Could you explain it a bit more with some code example?

@sergey-chernikov
Copy link
Author

sergey-chernikov commented Jan 24, 2025

SomeObj::SomeObj(...)
{
      http_ = std::make_shared<httplib::Server>();
      http_->Get("/.*", [this](const httplib::Request& req, httplib::Response& resp)
      {
         processHttp(req, resp);
      });
      httpListenThread_ = std::thread([srv = http_, settings] {
         srv->listen(settings["http"]["host"].get<std::string>().c_str()
            , settings["http"]["port"].get<int>());
      });
}
...
void SomeObj::processHttp(const httplib::Request& req, httplib::Response& resp)
{
      logger_->debug("[{}::processHttp] {} {}: {} -> {}", name(), req.method
         , req.path, req.body, req.target);
      for (const auto& p : req.path_params) {
         logger_->debug("[{}::processHttp::PP] {} = {}", name(), p.first, p.second);
      }
      for (const auto& p : req.params) {
         logger_->debug("[{}::processHttp::P] {} = {}", name(), p.first, p.second);
      }
}

when handling the request above provides only the following output:
[SomeObj::processHttp] GET /: -> /
I.e. the data after # is lost and not available even for manual retrieval.

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

No branches or pull requests

2 participants