check this out and tell your feedback and open sourced
https://crates.io/crates/nous/0.1.10-beta
It looks very interesting and I absolutely love your builder like approach. You may want to add websocket support too. Keep us updated on the progress.
1 Like
Have you considered simplifying the response types a bit? I can't seem to understand why there are 3 of them.
In my opinion the "defining routes" example could look like this:
use gates_rs::{Request, Response};
// POST request handler
#[gates(post = "/billionaire", gatekeeper = billionairehari)]
fn basicb(b: &Request) -> Response {
println!("{}", b.body);
Response::new().status(200).message("")
}
1 Like
sure ill simplyfy the usage
you can try out gates_dope
#[gates_dope("/ws/billionairegreathariprasath")]
fn billionaire(b: &mut GatesDope) {
b.send("billionairegreathariprasath".into());
match b.read() {
Ok(Message::Text(b)) => {
println!("{}", b);
}
Err(err) => {
println!("{}", err);
}
_ => {}
}
}
Gates::new()
.port("127.0.0.1:7878")
//.middleware(nous::Middleware::cors(&cors))
//.middleware(nous::Middleware::compression("gzip"))
//.routes(&[billionairegreat, billionairegreathari, billionaireb])
.ws_routes(&[b, billionaire])
//.statics("app", nous::Static::All)
// .rate_limit(nous::RL::FixedLimit(9, 60, "/l0/*"))
// .rate_limit(nous::RL::FixedLimit(9, 60, "/billionaires"))
.run();
you can try out adding 0.1.10-beta
#[gates(get = "/api/billionairegreathariprasath")]
fn billionairegreat(b: &GatesRequest) -> GateKeeperResponse {
println!("{}", b.method);
GatesRedirect::redirect(302, "/billionaire")
}
#[gates(post = "/billionairegreathari")]
fn billionairegreathari(b: &GatesRequest) -> GateKeeperResponse {
println!("{}", b.body);
println!("{}", b.method);
GatesResponse::new().status(200).message("")
}
I need to steal the code for - compression("gzip").
you can go through flate2 docs in cargo