General Rust Actix Applications and AWS Programming Utilities

Overview

RUST Actix-Web Microservice


Our Rust Beginners Kit for Application Development

A collection of sample code using the actix rust framework to

A) Develop REST API

Sample Code :

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

B) Road Map

  • Integrate with Generally used Amazon Web Services ( coming soon )
  • Integrate with Elastic Search
  • Better Error handling

C) Features :

  • Actix Web framework
  • Serde serialization framework
  • Bcrypt for password hashing
  • JWT token Based Authontication
  • Postgres databse
  • Use of Diesel ORM

D) Dependencies:

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
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

E) Run locally

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!

F) Example requests

1) Register

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":"[email protected]",
        "mobile":"123456789",
        "password":"1313n218u41",
        "ip_address":"124.245.55.124",
        "isactive":true
}'

2) Login

curl -i --request POST \
  --url http://0.0.0.0:9000/login \
  --header 'content-type: application/json' \
  --data '{ "username":"admin","password":"1313n218u41"}'

3) View Holidays

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" }'
You might also like...
Drop-in replacement for the Actix Web HTTP Logger middleware

actix-contrib-logger Logger middleware for the Actix Web framework. Actually it's a copy & paste from the official Logger middleware (original source

An Interpreter for Brainfuck programming language implemented in the Rust programming language with zero dependencies.

Brainfuck Hello, Visitor! Hey there, welcome to my project showcase website! It's great to have you here. I hope you're ready to check out some awesom

Programming language made by me to learn other people how to make programming languages :3
Programming language made by me to learn other people how to make programming languages :3

Spectra programming language Programming language made for my tutorial videos (my youtube channel): Syntax Declaring a variable: var a = 3; Function

Sets of libraries and tools to write applications and libraries mixing OCaml and Rust

Sets of libraries and tools to write applications and libraries mixing OCaml and Rust. These libraries will help keeping your types and data structures synchronized, and enable seamless exchange between OCaml and Rust

 create and test the style and formatting of text in your terminal applications
create and test the style and formatting of text in your terminal applications

description: create and test the style and formatting of text in your terminal applications docs: https://docs.rs/termstyle termstyle is a library tha

CarLI is a framework for creating single-command and multi-command CLI applications in Rust

CarLI is a framework for creating single-command and multi-command CLI applications in Rust. The framework provides error and IO types better suited for the command line environment, especially in cases where unit testing is needed.

Background task processing for Rust applications with Tokio, Diesel, and PostgreSQL.
Background task processing for Rust applications with Tokio, Diesel, and PostgreSQL.

Async persistent background task processing for Rust applications with Tokio. Queue asynchronous tasks to be processed by workers. It's designed to be

Upkeep your websites and web applications with ease from the comfort of the command line.
Upkeep your websites and web applications with ease from the comfort of the command line.

Upkeep Upkeep your websites and web applications with ease from the comfort of the command line. Explore the docs » View Demo · Report Bug · Request F

Start and stop system for applications to save your budget on hourly billing VPS.

Start and stop system (STT) Start and stop system for applications to save your budget on hourly billing VPS. Service A service consists of start/stop

Comments
  • some clippy, rustfmt, cargo and syntax fixes

    some clippy, rustfmt, cargo and syntax fixes

    The changes I did not apply:

    error: an async construct yields a type which is itself awaitable
      --> src/controller/awsc.rs:23:5
       |
    13 |    pub async fn lambda_example_synchronus() -> HttpResponse {
       |   __________________________________________________________-
    14 |  |     //create AWS Lambda client with Region same as region of Lambda funmction (This uses AWS credentials from .env file)
    15 |  |     let client = LambdaClient::new(Region::ApSoutheast1);
    16 |  |     //Create body of Invocation Request
    ...   |
    23 | /|     match client.invoke(request).await {
    24 | ||         Ok(response) => match response.payload {
    25 | ||             Some(b_body) => {
    26 | ||                 let vec_body = b_body.to_vec();
    ...  ||
    55 | ||         }
    56 | ||     }
       | ||_____^ awaitable value not awaited
    57 |  | }
       |  |_- outer async construct
       |
       = note: `#[deny(clippy::async_yields_async)]` on by default
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#async_yields_async
    help: consider awaiting this value
       |
    23 |     match client.invoke(request).await {
    24 |         Ok(response) => match response.payload {
    25 |             Some(b_body) => {
    26 |                 let vec_body = b_body.to_vec();
    27 |                 match String::from_utf8(vec_body) {
    28 |                     Ok(body) => {
     ...
    
    error: this loop never actually loops
      --> src/controller/awsc.rs:70:17
       |
    70 | /                 while let Some(chunk) = field.next().await {
    71 | |                     //Convert from bytes to bytestream
    72 | |                     let data = chunk.unwrap().to_vec();
    73 | |                     let bst = ByteStream::from(data);
    ...  |
    81 | |                     };
    82 | |                 }
       | |_________________^
       |
       = note: `#[deny(clippy::never_loop)]` on by default
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#never_loop
    
    warning: very complex type used. Consider factoring parts into `type` definitions
      --> src/middleware/auth.rs:46:19
       |
    46 |     type Future = Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>>>>;
       |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       |
       = note: `#[warn(clippy::type_complexity)]` on by default
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_complexity
    
    
    opened by sn99 1
  • some clippy, rustfmt, cargo and syntax fixes

    some clippy, rustfmt, cargo and syntax fixes

    The changes I did not apply:

    error: an async construct yields a type which is itself awaitable
      --> src/controller/awsc.rs:23:5
       |
    13 |    pub async fn lambda_example_synchronus() -> HttpResponse {
       |   __________________________________________________________-
    14 |  |     //create AWS Lambda client with Region same as region of Lambda funmction (This uses AWS credentials from .env file)
    15 |  |     let client = LambdaClient::new(Region::ApSoutheast1);
    16 |  |     //Create body of Invocation Request
    ...   |
    23 | /|     match client.invoke(request).await {
    24 | ||         Ok(response) => match response.payload {
    25 | ||             Some(b_body) => {
    26 | ||                 let vec_body = b_body.to_vec();
    ...  ||
    55 | ||         }
    56 | ||     }
       | ||_____^ awaitable value not awaited
    57 |  | }
       |  |_- outer async construct
       |
       = note: `#[deny(clippy::async_yields_async)]` on by default
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#async_yields_async
    help: consider awaiting this value
       |
    23 |     match client.invoke(request).await {
    24 |         Ok(response) => match response.payload {
    25 |             Some(b_body) => {
    26 |                 let vec_body = b_body.to_vec();
    27 |                 match String::from_utf8(vec_body) {
    28 |                     Ok(body) => {
     ...
    
    error: this loop never actually loops
      --> src/controller/awsc.rs:70:17
       |
    70 | /                 while let Some(chunk) = field.next().await {
    71 | |                     //Convert from bytes to bytestream
    72 | |                     let data = chunk.unwrap().to_vec();
    73 | |                     let bst = ByteStream::from(data);
    ...  |
    81 | |                     };
    82 | |                 }
       | |_________________^
       |
       = note: `#[deny(clippy::never_loop)]` on by default
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#never_loop
    
    warning: very complex type used. Consider factoring parts into `type` definitions
      --> src/middleware/auth.rs:46:19
       |
    46 |     type Future = Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>>>>;
       |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       |
       = note: `#[warn(clippy::type_complexity)]` on by default
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_complexity
    
    opened by sn99 0
Owner
IntelliConnect Technologies
We Build The RIGHT Solutions To TRANSFORM & GROW Your Business! We are on a mission to democratize cutting-edge technologies!
IntelliConnect Technologies
A library to provide abstractions to access common utilities when developing Dioxus applications.

?? Dioxus Standard Library ?? A platform agnostic library for supercharging your productivity with Dioxus. dioxus-std is a Dioxus standard library tha

Miles Murgaw 5 Nov 9, 2022
Umpteen is a general-purpose programming language currently in active development being bootstrapped from Rust

The Umpteen Programming Language This repository provides the reference implementation for the Umpteen Programming Language, bootstrapped from Rust. U

Katie Janzen 4 Nov 20, 2023
A general-purpose, transactional, relational database that uses Datalog and focuses on graph data and algorithms

cozo A general-purpose, transactional, relational database that uses Datalog for query and focuses on graph data and algorithms. Features Relational d

null 1.9k Jan 9, 2023
Fuzzy a general fuzzy finder that saves you time in rust!

Life is short, skim! Half of our life is spent on navigation: files, lines, commands… You need skim! It is a general fuzzy finder that saves you time.

Jinzhou Zhang 3.7k Jan 8, 2023
General purpose memory allocator written in Rust.

Memalloc Memory allocator written in Rust. It implements std::alloc::Allocator and std::alloc::GlobalAlloc traits. All memory is requested from the ke

Antonio Sarosi 35 Dec 25, 2022
A simplified general-purpose queueing system for Rust apps.

A simplified general-purpose queueing system for Rust apps. Example // Create a new Redeez object, and define your queues let mut queues = Redeez::new

Miguel Piedrafita 11 Jan 16, 2023
General purpose cross-platform GIS-rendering library written in Rust

Galileo is a general purpose cross-platform geo-rendering library. Web examples Raster tile layer (OSM) Vector tile layer (Maplibre) Use buttons at th

Maxim 16 Dec 15, 2023
Conference Monitoring Project based on Image Recognition that uses Rust Language and AWS Rekognition service to get the level of image similarity.

Conference Monitoring System based on Image Recognition in Rust This is a Conference Monitoring Project based on Image Recognition that uses Rust Lang

Pankaj Chaudhary 6 Dec 18, 2022
A general purpose Lisp🛸 intended for use as Sage's preprocessor language

sage-lisp This crate implements a standalone Lisp implementation, intended for use in the Sage preprocessor. (do (defun fact (n) (if (<=

adam mcdaniel 3 Apr 10, 2024
🦀🔨 DevBcn Workshop - Full Stack Rust - Actix - Postgres - Shuttle - Dioxus

Building a Movie Collection Manager - Full Stack Workshop with Rust, Actix, SQLx, Dioxus, and Shuttle Welcome to the this workshop! In this hands-on w

BcnRust 57 Jul 12, 2023