Skip to content

prscoelho/realworld-tide

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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":"hello@example.com","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":"hello@example.com","password":"password"}}' \
     http://localhost:8080/api/users/login

Cleaning up

To stop and delete the db container and volume:

docker-compose down

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published