A simple API made with Rust!
Rust API is an API created for my studies on rust and REST APIs.
This api stores a user creation system, as well as a login system with authentication and validation of parameters, functions such as listing users, editing and deleting them.
After downloading the source code, run the following command to download the dependencies and build the project:
cargo build
Then set these environment variables in .env file:
HOST="127.0.0.1"
PORT=3000
DATABASE_URL=
JWT_SECRET=
Then run the following command to run the server:
cargo run
POST /users
Fields:
{
"username": "[USERNAME]",
"email": "[EMAIL]",
"password": "[PASSWORD]"
}
Response:
{
"id": "[ID]",
"username": "[USERNAME]",
"email": "[EMAIL]"
}
GET /users
Response:
[
{
"id": "[ID]",
"username": "[USERNAME]",
},
...
]
GET /users/{ID}
Response:
{
"id": "[ID]",
"username": "[USERNAME]",
"email": "[EMAIL]"
}
POST /login
Fields:
{
"email": "[EMAIL]",
"password": "[PASSWORD]"
}
Response:
{
"token": "[TOKEN]"
}
PUT /users
Requires authentication
Fields:
{
"username": "[USERNAME]",
"email": "[EMAIL]",
"password": "[PASSWORD]"
}
Response:
{
"message": "User updated successfully!"
}
DELETE /users
Requires authentication
Fields:
{
"password": "[PASSWORD]"
}
Response:
{
"message": "User deleted successfully!"
}