I'd like to use pion 5.0.6 as a small webserver in a VS2017 c++ project. For static routes I can use
add_resource("/my/static/route", <handler>)
I would need dynamic routes as well - like "/data/:id/info
How do I do this?
) I wou" /> ) I wou" /> ) I wou"/>
I'd like to use pion 5.0.6 as a small webserver in a VS2017 c++ project. For static routes I can use
add_resource("/my/static/route", <handler>)
I would need dynamic routes as well - like "/data/:id/info
How do I do this?
Copyright © 2021 Jogjafile Inc.
For those who may need it: I found a solution to add dynamic routing to the pion webserver. It requires smart router code I found at hxoht on github, and works the way that
httpd->add_resource(<url>, <handler);httpd->set_not_found_handler(<handler>);and is responsible for dispatching the dynamic routes to the handlers added above.pion::http::serverin order to find the handler by name withhttpd->find_request_handler(<url>, <handler>);in your 404-handler, you use the
Match::test(<dynamic-route>)method to detect a dynamic route - like in the following code fragment:For using the pion webserver in a multi-threaded way, I would store the parsed value inside the request object, which would be derived from
pion::http::request.This would work for Windows and Linux :)