Expand description
Lumine
A lightweight asynchronous HTTP framework built with Rust and Tokio.
Lumine is designed to be:
- Fast — Minimal overhead with efficient async I/O.
- Simple — Small API surface and easy-to-follow architecture.
- Flexible — Build applications without fighting framework abstractions.
- Correct — Strictly follows HTTP/1.1 spec with proper headers, status codes, and edge-case handling.
§Why Lumine?
Many Rust web frameworks provide powerful features, but can introduce significant complexity.
Lumine aims to provide:
- A lightweight and approachable HTTP framework
- A straightforward async-first architecture
- Full control over request handling and responses
- An API that stays close to idiomatic Rust
§Minimal Usage
use lumine::prelude::*;
use tokio::net::TcpListener;
#[tokio::main]
async fn main() -> std::io::Result<()> {
let app = Lumine::builder()
.route("/", async |_| "Hello, World!")
.build();
let listener = TcpListener::bind("127.0.0.1:8080").await?;
app.serve(listener).await;
Ok(())
}§Request Handlers
Handlers receive a Request and return any type implementing IntoResponse.
Inline async closure:
use lumine::prelude::*;
let app = Lumine::builder()
.route("/", async |request: Request| {
format!("Requested: {}", request.uri().path())
})
.build();Or use a dedicated async function:
use lumine::prelude::*;
async fn index(request: Request) -> impl IntoResponse {
format!("Requested: {}", request.uri().path())
}
let app = Lumine::builder()
.route("/", index)
.build();§Responses
Anything that implements IntoResponse can be returned from handlers.
use lumine::prelude::*;
async fn plain_text(_: Request) -> &'static str {
"Hello, World!"
}
async fn json(_: Request) -> impl IntoResponse {
let mut headers = HeaderMap::new();
headers.insert(header::CONTENT_TYPE, HeaderValue::from_static("application/json"));
(StatusCode::CREATED, headers, "Hello, World!")
}
let app = Lumine::builder()
.route("/", plain_text)
.route("/json", json)
.build();§Examples
More examples can be found in the examples/ directory.
Run an example:
cargo run --example <example-name>§License
Licensed under the MIT License.
Modules§
- application
- Application core and type-state system.
- body
- HTTP response body representation.
- error
- Error handling definitions for the Lumine framework.
- filestream
filestream - File streaming and attachment handling.
- middleware
- Middleware system for request and response processing.
- prelude
- The Lumine prelude.
- request
- HTTP Request handling for Lumine.
- response
- HTTP Response handling for Lumine.
- stream
- Core trait for data streaming.
Structs§
- Addr
- The remote IP address of the client that initiated the request.
- File
Stream filestream - A file stream for HTTP responses.
- Limits
- Resource limits for the HTTP server.
- Lumine
- The main HTTP application structure.
- Next
- Represents the remaining execution chain of middlewares.
- Params
- Represents path parameters extracted from a matched route.
- Query
- Represents query parameters extracted from the request URI.
- Remainder
- Represents the trailing path matched by a wildcard route segment.
- Timeouts
- Configuration for operation timeouts.
Enums§
- Body
- Represents the body of an HTTP response.
- Disposition
filestream - Represents the
Content-Dispositionof a file.
Traits§
- From
Request - Into
Body - Converts a value into an HTTP-compatible body.
- Into
Response - Converts a value into an HTTP response.
- Middleware
- Trait for creating HTTP middleware.
- Stream
- A trait for types that can provide data in chunks.