Crates.io | webdev_guide |
lib.rs | webdev_guide |
version | 0.6.0 |
source | src |
created_at | 2024-03-09 15:38:42.644689 |
updated_at | 2024-03-09 17:52:39.103811 |
description | Learn how to build a webservice in Rust! |
homepage | |
repository | https://github.com/obaraelijah/webdev_tutorial |
max_upload_size | |
id | 1167912 |
size | 123,123 |
This project serves as a comprehensive tutorial for building a web service using the Rust programming language. It covers various aspects, from setting up a PostgreSQL database to handling JSON responses.
.env
files.To generate documentation for this project:
cargo doc --open
Environment Variables: Copy the sample environment file and configure the variables.
cp env.example .env
Docker Compose: Start the Docker containers.
docker compose up -d
Upload Postman Collection: Open up Postman locally via the desktop client. Then upload the file entitled Web Service Tutorial.postman_collection.json
. You should now have access to the Postman collection.
Get a Bearer Token:
create_user
route under the auth
folder.Send
button. If there's a problem, change both the username and password.authorization
header, you should see the bearer token. Copy everything after where it says Bearer
.Web Service Tutorial
Postman collection.Authorization
page, you should see a Type
dropdown.Bearer Token
. After you select Bearer Token
, underneath should apear another dropdown that says Token
. Paste the copied bearer token here from before. You should now be authorized for four hours, or for however long JWT_HOURS_ACTIVE
is set to in your .env file.localhost:8080
to http://127.0.0.1:8080
Test Routes: Open your browser or use a tool like Postman to hit the following route:
http://127.0.0.1:8080/blog
http://localhost:16543
.test@test.com
test
For detailed instructions on adding a PostgreSQL server in PgAdmin4, refer to the PG Admin guide.
The init.sql
file contains the SQL statements that define the database schema. Feel free to explore it to understand the database structure.
The SKIP_AUTH
environment variable controls JWT authentication. Set it to true
to disable JWT during development.