7 releases

new 0.5.3 Jan 14, 2025
0.5.2 Dec 31, 2024
0.4.5 Sep 9, 2024
0.4.1 Jul 7, 2024
0.2.8 Nov 26, 2023

#113 in HTTP server

Download history 38/week @ 2024-09-23 10/week @ 2024-09-30 26/week @ 2024-12-09 295/week @ 2024-12-16 13/week @ 2024-12-23 128/week @ 2024-12-30 9/week @ 2025-01-06

446 downloads per month
Used in ngyn-swagger

MIT license

84KB
1.5K SLoC

ngyn

ngyn (pronounced "engine")

Crates.io Docs.rs License MSRV Made in Nigeria

A modern, ergonomic web framework written in Rust for building high-performance web applications.

Documentation | Getting Started | Examples | Contributing

Overview

Ngyn is designed to make building web servers in Rust both enjoyable and productive. It combines ergonomic APIs with performance-focused design, making it suitable for everything from small APIs to large-scale web applications.

Features

  • Intuitive Routing: Simple, declarative routing patterns (app.get(), /users/{id}) familiar to web developers
  • Flexible Middleware: Asynchronous middleware system for request/response processing
  • Performance Focused: Optimized for both development experience and runtime performance
  • Modern Rust: Takes advantage of Rust's type system and async features
  • Optional Macros: Enhance your route handlers with minimal boilerplate
  • Platform Agnostic: Built to work with various HTTP servers (currently supports Hyper)

Getting Started

Add ngyn to your Cargo.toml:

[dependencies]
ngyn = "0.5"
tokio = { version = "1", features = ["full"] }

Create a basic web server:

use ngyn::prelude::*;

#[handler]
fn hello() -> &'static str {
    "Hello World!"
}

#[tokio::main]
async fn main() {
    let mut app = HyperApplication::default();
    
    // Handle all routes and HTTP methods
    app.any("*", hello);
    
    println!("Server running at http://127.0.0.1:8080");
    let _ = app.listen("127.0.0.1:8080").await;
}

Examples

Check out our examples directory for more use cases:

  • Basic routing
  • Middleware usage
  • Authentication
  • JSON APIs
  • WebSocket handling
  • Database integration

Core Crates

  • ngyn: The main framework, reexports all other crates
  • ngyn-macros: Procedural macros for route handlers
  • ngyn-shared: Core traits and types
  • ngyn-hyper: Hyper server integration
  • ngyn-ws: WebSocket support
  • ngyn-shuttle: Shuttle.rs deployment service integration
  • ngyn-vercel: Vercel deployment service integration

Roadmap

Ngyn is under active development, with the following features planned for future releases:

  • Request and response body handling
  • Form parsing and validation
  • Cookies and sessions management
  • Form Handling
  • File uploads
  • Custom response types
  • WebSockets
  • Middlewares for common tasks
  • Static file serving
  • Internationalization and localization
  • Caching and compression
  • Testing utilities
  • CLI tooling for project generation (In progress)
  • Rate limiting and security features
  • Deployment service integrations
    • Shuttle.rs
    • Vercel
    • Netlify
    • Cloudflare Workers
  • Improved documentation and examples (In progress)
    • GraphQL support
    • Authentication and authorization
    • Error handling and logging

Performance

Ngyn is designed to be performant while maintaining developer productivity. Some key performance features:

  • Zero-cost abstractions
  • Efficient routing algorithm
  • Minimal allocations
  • Async-first design

How to Contribute

Ngyn thrives on community support and contributions! Here’s how you can get involved:

  1. Report Issues: Found a bug? Let us know by opening an issue on GitHub.
  2. Suggest Features: Have an idea for an improvement? Share it with us!
  3. Submit Pull Requests: Fix bugs or implement new features to help make Ngyn even better.

If Ngyn has been helpful, consider giving it a star on GitHub to support the project!

Please read our Contributing Guide for more details.

Community

Status

Ngyn is under active development. While the core API is stabilizing, some features might change. Production use should be carefully evaluated.

License

Ngyn is licensed under the MIT License. This allows you to use, modify, and distribute the framework freely in your projects.


We can’t wait to see what you build with Ngyn! 🚀

Dependencies

~10–18MB
~293K SLoC