Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

samkpo
Copy link

@samkpo samkpo commented Sep 17, 2023

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.

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

```c++
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);
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant