| Crates.io | xpress |
| lib.rs | xpress |
| version | 0.2.0 |
| created_at | 2024-11-19 16:27:57.499786+00 |
| updated_at | 2025-04-18 22:54:50.067877+00 |
| description | A minimal HTTP library. |
| homepage | |
| repository | https://github.com/MikhailWahib/xpress |
| max_upload_size | |
| id | 1453498 |
| size | 22,145 |
Xpress is a minimalistic, HTTP framework built from scratch in Rust. It aims to demonstrate the inner workings of web frameworks by implementing core features like routing, request parsing, and response handling in a simple yet extensible way.
Note: This project is not intended for production use. It is designed to be a simple example of how an HTTP framework could be built from scratch in Rust, and should not be used in production environments.
GET, POST, PUT, and DELETE methods.Add Xpress to your project by including it in your Cargo.toml:
[dependencies]
xpress = "0.1.3"
Here's a quick example to get started with Xpress:
use serde::{Deserialize, Serialize};
use std::sync::{Arc, Mutex};
use xpress::Xpress;
#[derive(Serialize, Deserialize, Clone)]
struct User {
name: String,
age: u8,
email: String,
}
fn main() {
let mut app = Xpress::new("127.0.0.1:8080");
let state = Arc::new(Mutex::new(Vec::new()));
// Define routes
app.get("/", |_req, res| res.html("hello.html").unwrap());
let users_state = Arc::clone(&state);
app.get("/users", move |_req, res| {
let users = users_state.lock().unwrap();
res.json(&*users).unwrap();
});
app.listen();
}
Contributions are welcome! Feel free to submit issues or pull requests to improve functionality, fix bugs, or add examples.
This project is licensed under the MIT License.