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

default rest api reouter added. RestApiRouter sample has been added. #1680

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,29 @@ We'd love to get your review score, whether good or bad, but even more than that

This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [[email protected]](mailto:[email protected]) with any additional questions or comments.

## Rest API Router:
You can find sources under "Release/samples/RestApiRouter". I've created a sample only for showing you how easy it is to use,
I'm using gcc under WSL (debian) and Postman for testing ednpoints:
Compile & Build:
```bash
g++ -std=c++11 restapirouter.cpp -o sample -lcrypto -lcpprest -lpthread
```
```bash
./sample
```
![image](https://user-images.githubusercontent.com/56490683/152418716-dcb77f03-4fa1-4891-9714-cfdda05b919e.png)

Use Postman to send a request (Method: GET , Body: {"name":"test"}, Endpoint: /api/v1/api1/action1):

![image](https://user-images.githubusercontent.com/56490683/152419500-1c3f3515-45b5-42a8-9c60-0be4a124db7f.png)

Use Postman to send a request (Method: POST , Body: {"name":"test", "username":"testuser"}, Endpoint: /api/v1/api2/action2):

![image](https://user-images.githubusercontent.com/56490683/152419758-a303b6ae-da49-445a-967e-ba6e82529ae4.png)

What if we requested a not defined endpoint:
Use Postman to send a request (Method: POST , Body: {"name":"test", "username":"testuser"}, Endpoint: /api/v1/api2/**action3**):

![image](https://user-images.githubusercontent.com/56490683/152419929-ba197ee6-112d-458d-8259-ff1035b57b36.png)

Thats all.
Loading