Skip to content

🔥 REST API Service using Rust & Rocket with MongoDB as backend

License

Notifications You must be signed in to change notification settings

Speccy-Rom/rust_rocket_mongo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rocket Mongo

build GitHub

A Simple Skeleton API Rest server using Rocket with the backend database as MongoDB.

Features

  • Custom config file defining:
    • server host ip and port to listen
    • enable/disable ssl with ssl cert auto generation
    • mongodb configurations
  • Use the x-api-key header to validate API Keys
  • Restrict a client connecting IP Addresses to the endpoints using Allow ACL
  • Restrict endpoints using the Allow ACL

Requirements

  • Rust 1.56+ (2021 edition)

Compile

cargo build --release
  • Sample config file is available at config.yml

Available endpoints

  • Index/User management endpoint
Description Endpoint Method
Api index / GET
List all Users /users GET
Create user /users POST
Update user /users PUT
Delete user /users/<Email> DELETE

POST Request for new user creation / user update

The below example goes into json body of POST/PUT request while creating a new user

{
  "email": "email",
  "description": "...",
  "is_admin": false,
  "acl_allow_ips": ["127.0.0.1", "<IP_ADDRESS>"] // use ["*"] if you want to allow from any IP
  "acl_allow_endpoints": ["/users"] // use ["*"] if you want to allow all endpoints access
}

Seed data & Configuration

{
  "created_ip" : "127.0.0.1",
  "created_by" : "email",
  "created_at" : "2021-08-02T00:00:00Z",
  "email" : "email",
  "description": "...",
  "api_key" : "apikey123",
  "is_admin" : true,
  "acl_allow_ips" : ["*"],
  "acl_allow_endpoints": ["*"]
}

License: MIT

About

🔥 REST API Service using Rust & Rocket with MongoDB as backend

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages