thanks to inarust for the boilerplate ๐คฉ
-
Copy .env.example to .env
mv .env.example .env
-
Set your database connection and your server host to serve this web on your new .env file
nano .env
DB_URL=<MONGO DB CONNECTION STRING> DB_NAME=<DATABASE NAME> HOST=<HOST>:<PORT>
example value
DB_URL=mongodb://localhost:27017 DB_NAME=mydatabase HOST=0.0.0.0:8080
-
Run your web server with cargo on your terminal
cargo run
-
Test your web server
-
test using curl from your terminal
curl --request GET \ --url http://localhost:8080/
curl --request POST \ --url http://localhost:8080/user \ --header 'Content-Type: application/json' \ --data '{ "username": "Coba Lag", "email": "[email protected]" }'
curl --request GET \ --url http://localhost:8080/users
curl --request GET \ --url http://localhost:8080/user/fbcbac32-c05b-4f63-82fd-cc82ab53e103
curl --request PUT \ --url http://localhost:8080/user/fbcbac32-c05b-4f63-82fd-cc82ab53e103 \ --header 'Content-Type: application/json' \ --data '{ "username": "Inara 2", "email": "[email protected]" }'
curl --request DELETE \ --url http://localhost:8080/user/bab2d00f-27bc-425f-9f45-1f1873884329
-
test using api client, im using bruno Lihat pada folder doc
-
-
Build for deployment, you can build your rust app with cargo using this command in your terminal
cargo build