Skip to content

Latest commit

 

History

History
77 lines (47 loc) · 1.5 KB

README.md

File metadata and controls

77 lines (47 loc) · 1.5 KB

The authentication routes of the realworld spec api in Rust with Tide-rs

API Spec

Tide

Routes

https://github.com/gothinkster/realworld/tree/master/api#authentication

Login

POST /api/users/login

Register

POST /api/users

Get current user (requires login token)

GET /api/user

Update user (requires login token)

PUT /api/user

Running

Since our sql statements are being verified at compile time, the database must be running before we compile the project.

Start the database

docker-compose up -d

Running

With the database up:

cargo run --release

Testing routes

Endpoint is served at localhost:8080

Register

curl --header "Content-Type: application/json" \
     --request POST \
     --data '{"user":{"username":"hello","email":"[email protected]","password":"password"}}' \
     http://localhost:8080/api/users

Verify login

The previous register response should contain a token field, replace $token with it:

curl --header "Content-Type: application/json" \
     --header "Authorization: Token $token" \
     --request GET \
     http://localhost:8080/api/user

Login

curl --header "Content-Type: application/json" \
     --request POST \
     --data '{"user":{"email":"[email protected]","password":"password"}}' \
     http://localhost:8080/api/users/login

Cleaning up

To stop and delete the db container and volume:

docker-compose down