matt-42 / lithium

Easy to use C++17 HTTP Server with no compromise on performances. https://matt-42.github.io/lithium
https://matt-42.github.io/lithium
MIT License
1.26k stars 91 forks source link

Use the base path provided in method "add_subapi" for an api path. #127

Open samkpo opened 1 year ago

samkpo commented 1 year ago

If a subapi is created this will allow to define an endpoint like this very one if desired:

http_api subapi;
subapi.get("/") = [&](http_request& request, http_response& response) {
    response.write("hello");
};
subapi.get("/world") = [&](http_request &request, http_response &response) {
    response.write("hello world");
};

http_api my_api;
my_api.add_subapi("/hello", &subapi);

It allows us to definea method within the subapi route by the subapi itself.