cpp-httplib: Query-Parameter abfragen
English
Deutsch
Dieses Beispiel zeigt, wie man einen Query-Parameter in cpp-httplib abfragt. Siehe das cpp-httplib Hello-Beispiel für den vollständigen Quellcode:
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");
});Greife darauf zu unter http://localhost:8080/hi?id=myid
und es zeigt dir
query_param_output.txt
id=myidid ist leer (== ""), wenn kein solcher Parameter angegeben wird.
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