cpp-httplib: How to get query parameters

This example shows how to get a query parameter in cpp-httplib. See the cpp-httplib hello example for the full source code:

svr.Get("/hi", [](const httplib::Request& req, httplib::Response& res) {
    std::string id = req.get_param_value("id");
    res.set_content("id=" + id, "text/plain");

Access it at http://localhost:8080/hi?id=myid

and it will show you


id will be empty (== "") if no such parameter is given.