Skip to content

Latest commit

 

History

History
107 lines (82 loc) · 1.86 KB

File metadata and controls

107 lines (82 loc) · 1.86 KB

High-Performance HTTP Server in Rust

This project is a lightweight and high-performance HTTP server written in Rust.
It is designed with modular structure, concurrency, and real-time statistics tracking.


Features

  • Lightweight and minimal dependencies
  • Fast response for core endpoints:
    • GET / → returns "OK"
    • GET /stats → returns JSON with real-time statistics:
      • total_connections: number of requests since server start
      • rps: requests per second
  • Modular code structure:
    • server.rs → manages server lifecycle
    • routes.rs → defines HTTP routes
    • stats.rs → tracks server statistics
  • Built on Tokio and Hyper for asynchronous performance

Project Structure

src/
├─ main.rs       # Entry point
├─ server.rs     # HTTP server logic
├─ routes.rs     # Routing and responses
└─ stats.rs      # Real-time statistics
Cargo.toml       # Project configuration
Makefile         # Build and utility commands

Requirements

  • Rust (latest stable version recommended)
  • Cargo build system
  • Linux, macOS, or Windows

Build and Run

Build

make build

Run

make run

The server will start by default at: http://127.0.0.1:8080


Usage

  • Root endpoint:

    curl http://127.0.0.1:8080/

    Response:

    OK
    
  • Statistics endpoint:

    curl http://127.0.0.1:8080/stats

    Example response:

    {
      "total_connections": 42,
      "rps": 7
    }

Development

  • Format code:
    make fmt
  • Run linter:
    make check
  • Run tests:
    make test

License

This project is licensed under the MIT License.
You are free to use, modify, and distribute it under the terms of the license.