cpp-httplib:如何获取查询参数
此示例展示如何在 cpp-httplib 中获取查询参数。有关完整源代码,请参阅 cpp-httplib hello 示例:
get_query_param_cpp.cpp
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");
});在 http://localhost:8080/hi?id=myid 访问它
它将显示
query_param_output.txt
id=myid如果没有给出此类参数,id 将为空(== "")。
Check out similar posts by category:
C/C++
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow