This is a simple rust actix web server that connects to a postgres database.
cargo run
docker run -it -d --name some-postgres -e POSTGRES_USER=test -e POSTGRES_PASSWORD=123 -p 5432:5432 postgres
docker exec -it some-postgres psql -U test
CREATE DATABASE rust_db;
\c rust_db
CREATE TABLE users (
id SERIAL PRIMARY KEY,
name VARCHAR NOT NULL,
email VARCHAR NOT NULL
);
- Create User
curl -X POST -H "Content-Type: application/json" -d '{"name": "", "email": ""}' http://localhost:8080/create
- Get Users
curl -X GET http://localhost:8080/get_all
- Get User by ID
curl -X GET http://localhost:8080/get/:id
- Update User
curl -X PUT -H "Content-Type: application/json" -d '{"name": "", "email": ""}' http://localhost:8080/update/:id
- Delete User
curl -X DELETE http://localhost:8080/delete/:id