This rust program sets up a server that listens on port 8080 and handles incoming HTTP requests.
Run the next commands in your the terminal:
git clone https://github.com/ILoveThatLady/vanillars-server
cd vanillars-server/
Install the libraries.
Write in the terminal:
# path: /vanilars-server
cargo build
Run the server:
cargo run
Send some HTTP request (all are sample answers):
-
Open a new terminal.
-
Send a GET request to retrieve a list of all cats:
curl http://localhost:8080/cat
- Send a POST request to create a new cat with the name "Whiskers":
curl -X POST -H "Content-Type: application/json" -d '{"name": "Whiskers"}' http://localhost:8080/cat
- Send a GET request to retrieve a specific cat with ID 123:
curl http://localhost:8080/cat/123
- Send a PUT request to update the name of a cat with ID 123 to "Fluffy":
curl -X PUT -H "Content-Type: application/json" -d '{"name": "Fluffy"}' http://localhost:8080/cat/123
- Send a DELETE request to delete a cat with ID 123:
curl -X DELETE http://localhost:8080/cat/123