GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - marirs/rocketapi: API Rest Server using Rocket.rs

BranchesTags
Open more actions menu

Latest commit

 

History

11 Commits
11 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
configs
configs
 
 
docs
docs
 
 
src
src
 
 
.gitignore
.gitignore
 
 
Cargo.toml
Cargo.toml
 
 
README.md
README.md
 
 
config.sample.yml
config.sample.yml
 
 

Repository files navigation

API REST Server using Rocket.rs

Linux Arm7 Linux x86_64 macOS intel

A 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 Deny ACL
  • Rate limiter to throttle incoming requests to endpoints
  • Extend this rocketapi server's boiler plate; with your endpoints

architecture

Requirements

  • Rust 1.56+ (2021 edition)

Compile

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

Starting the server

./target/release/rocketapi -f config.sample.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": {
    "name": "/endpoint_name",
    "method": "GET", // use "*" if you want any methods to be allowed for this endpoint 
    "throttle": "4/min" // can use sec|min|hour|day
  }
}

Seed data & Configuration

  • Example with rate-limit (throttle)
{
  "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": [
    {"name": "/fair", "method": "*", "throttle": "4/min"}
  ]
}
  • Example without rate-limit
{
  "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": [
    {"name": "*", "method": "*"} 
  ]
}

Configs

The configs folder has configurations to start the server as a service and nginx config to server this rocketapi server in reverse proxy mode.

  • Start the rocketapi server as a service
1) copy the configs/rocketapi.service to /etc/systemd/system folder
2) systemctl enable rocketapi
3) systemctl start rocketapi
  • Then you can copy the configs/nginx.vhost to /etc/nginx/sites-enabled to access the rocketapi server via nginx.

If you need a python version, a python fastapi version can be found here.


Contribution

Feel free to make pull requests and make this better and/or contribute to its features.


Licensed under the Apache License, Version 2.0

About

API Rest Server using Rocket.rs

Topics

apiapi-restboilerplateboilerplate-applicationmongodbrocketrustrust-lang

Resources

Readme
Activity

Stars

5 stars

Watchers

2 watching

Forks

2 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.