A modern, ergonomic web framework written in Rust for building high-performance web applications.
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.
- 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)
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;
}
Check out our examples directory for more use cases:
- Basic routing
- Middleware usage
- Authentication
- JSON APIs
- WebSocket handling
ngyn
: The main framework, reexports all other cratesngyn_macros
: Procedural macros for route handlersngyn_shared
: Core traits and typesngyn-hyper
: Hyper server integrationngyn-websocket
: WebSocket supportngyn-shuttle
: Shuttle.rs deployment service integrationngyn-vercel
: Vercel deployment service integration
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
- Response Streaming
- WebSockets
- Async Middlewares
- Async Gates
- Static file serving
- Internationalization and localization
- Caching and compression
- CLI tooling for project generation (In progress)
- Rate limiting and security features (In progress)
- Deployment service integrations (In progress)
- Bare metal (Hyper)
- Shuttle.rs
- Vercel
- Netlify
- Cloudflare Workers
- Improved documentation and examples (In progress)
- GraphQL support
- Authentication and authorization
- Error handling and logging
- Testing utilities
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
Ngyn thrives on community support and contributions! Here’s how you can get involved:
- Report Issues: Found a bug? Let us know by opening an issue on GitHub.
- Suggest Features: Have an idea for an improvement? Share it with us!
- 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.
Ngyn is under active development. While the core API is stabilizing, some features might change. Production use should be carefully evaluated.
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! 🚀