Rust Rocket Sample

screenshot of Rust Rocket Sample
rocket

Fully working CRUD REST API example using Rust and Rocket.rs

Overview

rust-rocket-sample is a fully working CRUD REST API example built using Rust and the Rocket framework. It demonstrates various features such as connecting to MongoDB, handling errors, implementing CORS, and generating API documentation using okapi. It also provides test codes to verify the functionality of the API endpoints.

Features

  • MongoDB Connection: Establishes a connection to MongoDB using a custom fairing in Rocket.
  • Custom Error Handling: Implements error handling using Rocket Responder and okapi OpenApiGenerator.
  • CORS and Counter Fairing: Demonstrates the usage of fairings by implementing CORS and Counter fairings.
  • Customer Model: Includes an example model called "Customer" to showcase how Rust structs interact with MongoDB.
  • Request Guard: Implements a request guard using ApiKey to secure the REST API endpoints.
  • CRUD Endpoints: Provides simple CRUD endpoints using the Customer model.
  • Open API Documentation: Implements Open API documentation using okapi to automatically generate API documentation.
  • Testing: Provides test codes to validate the functionality of the API endpoints.

Summary

rust-rocket-sample is a comprehensive example of building a CRUD REST API using Rust and the Rocket framework. It covers various features including MongoDB integration, error handling, fairings, request guards, and API documentation generation. The provided test codes ensure the functionality of the API endpoints.

rocket
rocket

Rocket is a lightweight static site generator that emphasizes simplicity and performance. It avoids unnecessary tools and frontend frameworks, defaults to zero JavaScript, and offers automatic code splitting and filesystem-based routing for fast development.

template
Templates & Themes

A template or theme refers to a pre-designed layout or structure that provides a basic framework for building a specific type of application or website. It typically includes good design, placeholder content and functional features, allowing developers to customize and fill in the details according to their specific needs.