Skip to content

CoconutLorikeet/rest_rocket

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

rest_rocket

A fast, modular, and efficient RESTful API built with the Rocket web framework in Rust πŸš€.

Table of Contents


About

rest_rocket is a lightweight and scalable RESTful API designed to serve as a foundation for modern web applications and microservices. Built using the powerful Rocket framework, it emphasizes performance, security, and developer experience.

Features

βœ… Built on Rocket 0.5+ βœ… Modular architecture βœ… Type-safe request and response handling βœ… JSON support (via serde) βœ… Centralized error handling βœ… Easy-to-extend endpoints βœ… Environment-based configuration βœ… Ready for production deployment

Getting Started

Prerequisites

  • Rust (version 1.70+ recommended)
  • cargo package manager (comes with Rust)

Clone the Repository

git clone https://github.com/yourusername/rest_rocket.git
cd rest_rocket

Build the Project

cargo build --release

Run the Application

cargo run

The server will start on http://localhost:8000 by default.

API Overview

Here’s a quick overview of the available REST endpoints:

Method Endpoint Description
GET / Welcome message
GET /api/v1/items List all items
GET /api/v1/items/<id> Get item by ID
POST /api/v1/items Create a new item
PUT /api/v1/items/<id> Update an item
DELETE /api/v1/items/<id> Delete an item

Example: GET /api/v1/items

curl http://localhost:8000/api/v1/items

Response:

[
  {
    "id": 1,
    "name": "Example Item",
    "description": "This is an example."
  }
]

Project Structure

rest_rocket/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ main.rs            # Application entry point
β”‚   β”œβ”€β”€ routes.rs          # API route definitions
β”‚   β”œβ”€β”€ models.rs          # Data models and types
β”‚   β”œβ”€β”€ handlers.rs        # Request handlers
β”‚   β”œβ”€β”€ errors.rs          # Custom error handling
β”‚   └── config.rs          # Configuration loading
β”œβ”€β”€ Cargo.toml
└── README.md

Testing

Run all tests using:

cargo test

To run the app in development with auto-reloading, use:

cargo install cargo-watch
cargo watch -x run

Security

  • Input validation using serde and custom types
  • Centralized error handling to avoid leaking sensitive information
  • CORS support can be added easily
  • TLS and authentication can be integrated if needed

Contributing

Contributions are welcome! To contribute:

  1. Fork this repository
  2. Create a feature branch (git checkout -b feature/YourFeature)
  3. Commit your changes (git commit -m 'Add your feature')
  4. Push to the branch (git push origin feature/YourFeature)
  5. Open a Pull Request

Please make sure to follow the Rust API Guidelines.

License

This project is licensed under the MIT License. See the LICENSE file for details.


Made with ❀️ using Rust and Rocket.


---

βœ… If you’d like, I can help you generate the initial code structure (`main.rs`, `routes.rs`, etc.) too.

About

A fast, modular, and efficient RESTful API built with the [Rocket](https://rocket.rs) web framework in Rust πŸš€.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages