Crates.io | oxidy |
lib.rs | oxidy |
version | 0.5.0 |
source | src |
created_at | 2022-02-01 18:10:15.739085 |
updated_at | 2022-11-16 17:04:01.758985 |
description | Fast & Minimum Web Framework for Rust |
homepage | |
repository | https://github.com/oxidy-rs/oxidy |
max_upload_size | |
id | 525317 |
size | 45,877 |
Fast & Minimum Web Framework for Rust.
Built on top of Tokio Tcp with Tokio Runtime.
This project is highly inspired by express.js, koa.js & warp.rs.
This is a crate (Rust Module) available on crate.io. Before install oxidy download & install Rust.
[dependencies]
oxidy = "<version>"
tokio = { version = "<version>", features = ["full"] }
use oxidy::{Server, Context, Returns, route};
async fn route(mut c: Context) -> Returns {
c.response.body = "Hello World".to_owned();
(c, None)
}
#[tokio::main]
async fn main() {
let mut app = Server::new();
app.add(route!("get /", route));
app.run("127.0.0.1:3000").await;
}
use std::time::Instant;
use oxidy::{Server, Context, Returns, route, middleware, tail};
async fn mid(mut c: Context) -> Returns {
let start = Instant::now();
println!("Middleware Function");
c.response.body = "Middleware Function".to_owned();
c.next = true;
tail!{
c,
{
println!("Tail Function");
c.response.body = "Tail Function".to_owned();
println!("Response Time: {:?}", Instant::now().duration_since(start));
c
}
}
}
async fn route(mut c: Context) -> Returns {
println!("Route Function");
c.response.body = "Hello World".to_owned();
(c, None)
}
#[tokio::main]
async fn main() {
let mut app = Server::new();
app.add(middleware!(mid));
app.add(route!("get /", route));
app.run("127.0.0.1:3000").await;
}
profile.release
configuration to get highly optimize build.
Cargo.tomlThis project is licensed under the MIT | View License
Unless you explicitly state otherwise, any contribution intentionally submitted for this project by you, shall be licensed as MIT, without any additional terms or conditions.