| Functionality | API | Description | 
|---|---|---|
| Post JSON data and recieve JSON data | http://0.0.0.0:9000/register_user | Recieve user details, query to create new user and respond with status of request | 
| Post JSON data and recieve jwt token for auth | http://0.0.0.0:9000/login | Recieve username and passwrod, query and verify if credentials are correct, generate and respond with jwt | 
| Fetch JSON Array | http://0.0.0.0:9000/view_holidays | Recieve input year, query database for holiday dates and respond with results | 
| Raw Query example | http://0.0.0.0:9000/list_users | Raw sql query and Manually specifying sql datatypes for structs | 
| AWS Lambda function invoke | http://0.0.0.0:9000/lambda_example | Invoke the function synchronously | 
| Upload to AWS S3 | http://0.0.0.0:9000/upload_file | ---- | 
| Dynamodb Query | http://0.0.0.0:9000/dynamodb_example | Simple Dynamodb Query Example | 
Here's what does what:
| Crate | Description | 
|---|---|
| actix-web | Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust. | 
| Diesel | Diesel is a Safe, Extensible ORM and Query Builder for Rust | 
| Serde | Serde is a framework for serializing and deserializing Rust data structures | 
| rusoto | Rusoto is an AWS SDK for Rust. | 
| dotenv | Required for loading environment variables from .env file | 
| env_logger | Implements a logger that can be configured via environment variables. | 
| jsonwebtoken | To Create and parses JWT (JSON Web Tokens) | 
| http | A general purpose library of common HTTP types | 
| easy_password | Simple crate for password hashing | 
Before you get started, make sure that you have PostgreSQL, Rust, Cargo, and the Diesel CLI installed and that you have Postgres running somewhere.
# Fetch the repo
git clone https://github.com/intelliconnect/rust-lang-apps.git
# Add environment variables to .env file.
nano .env
diesel setup
diesel migration run
cargo check
cargo run # could take a while!curl -i --request POST \
  --url http://0.0.0.0:9000/register_user \
  --header 'content-type: application/json' \
  --data '{
        "firstname":"abc",
        "lastname":"bbq",
        "username":"admin",
        "email":"admin@gmail.com",
        "mobile":"123456789",
        "password":"1313n218u41",
        "ip_address":"124.245.55.124",
        "isactive":true
}'
curl -i --request POST \
  --url http://0.0.0.0:9000/login \
  --header 'content-type: application/json' \
  --data '{ "username":"admin","password":"1313n218u41"}'
curl -i --request GET \
  --url http://0.0.0.0:9000/view_holidays \
  --header 'content-type: application/json' \
  --header 'Authorization: Bearer <token>' \
  --data '{ "year": "2020" }'
curl -i --request GET \
--url http://0.0.0.0:9000/lambda_example \
--header 'content-type: application/json'
curl -i POST \
--url http://0.0.0.0:9000/upload_file   \
--header 'content-type: multipart/form-data' \
-F "file=@image_upload_test.jpg"
curl -i --request GET \
--url http://0.0.0.0:9000/dynamodb_example \
--header 'content-type: application/json' \
--data '{"id":"ICT"}'

