A Rusty Rocket fuelled with Diesel and secured by JWT
A Rusty Rocket 🚀 fuelled with Diesel 🛢 and secured by JWT 🔐
You can build and run app from source:
Or using Docker
rustup install nightly
rustup override set nightly
secret.key.sample
to secret.key
or create your own key by running head -c16 /dev/urandom > secret.key
in command line (Linux/UNIX only) and copy to /src
folderRocket.toml.sample
to Rocket.toml
and update the database connection string in url
key.cargo build --release
target/release/address_book_rest_api.exe
, on *UNIX: target/release/address_book_rest_api
docker-compose up
localhost:8000
POST /api/auth/signup
: Signup{
"username": string,
"email": string,
"password": string // a raw password
}
{
"message": "signup successfully",
"data": ""
}
{
"message": "error when signing up, please try again",
"data": ""
}
POST /api/auth/login
: Login{
"username_or_email": string,
"password": string // a raw password
}
{
"message": "login successfully",
"data": {
"token": string // bearer token
}
}
{
"message": "wrong username or password, please try again",
"data": ""
}
GET /api/address-book
: Get all people information{
"message": "ok",
"data": [
{
"id": int32,
"name": string,
"gender": boolean, // true for male, false for female
"age": int32,
"address": string,
"phone": string,
"email": string
}
]
}
GET /api/address-book/{id}
: Get person information by id{
"message": "ok",
"data": {
"id": int32,
"name": string,
"gender": boolean, // true for male, false for female
"age": int32,
"address": string,
"phone": string,
"email": string
}
}
{
"message": "person with id {id} not found",
"data": ""
}
GET /api/address-book/{query}
: Search for person information by keyword{
"message": "ok",
"data": [
{
"id": int32,
"name": string,
"gender": boolean, // true for male, false for female
"age": int32,
"address": string,
"phone": string,
"email": string
}
]
}
POST /api/address-book
: Add person information{
"name": string,
"gender": boolean, // true for male, false for female
"age": int32,
"address": string,
"phone": string,
"email": string
}
{
"message": "ok",
"data": ""
}
{
"message": "can not insert data",
"data": ""
}
PUT /api/address-book/{id}
: Update person information by id{
"name": string,
"gender": boolean, // true for male, false for female
"age": int32,
"address": string,
"phone": string,
"email": string
}
{
"message": "ok",
"data": ""
}
{
"message": "can not update data",
"data": ""
}
DELETE /api/address-book/{id}
: Delete person information by id{
"message": "ok",
"data": ""
}
{
"message": "can not delete data",
"data": ""
}
{
"message": "invalid token, please login again",
"data": ""
}