Yet another web server framework for rust.
Installation (without automatic openapi generation):
toml
[dependencies]
rweb = "0.3.0-alpha.1"
tokio = "0.2"
Since rweb
is based on warp, which features safety and correctness, rweb
has same property.
```rust use rweb::*; use serde::{Serialize, Deserialize};
fn output() -> String { String::from("this returns 200 with text/plain mime type") }
struct Product { id: String, title: String, }
fn products() -> Json
fn product(id: String) -> Json
fn newproduct(product: Json
struct SearchOption { query: String, limit: usize, page_token: String, }
fn search(_product: Query
async fn main() { serve(output().or(product()).or(products()).or(search())).run(([127, 0, 0, 1], 3030)).await; }
```
If you want to use websocket, just declare a parameter typed Ws
. It's all.
```rust use rweb::*;
fn example(ws: ws::Ws) -> String { String::new("use ws.on_upgrade or extra") } ```
rweb supports automatically generating openapi specification file based on your code.
See: docuementation for usage.
| Name | rweb | actix-web | gotham | iron | nickel | rocket | rouille | Thruster | Tide | tower-web | warp |
| ---------------- | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
| License | |
|
|
|
|
|
|
|
|
|
|
| Version |
|
|
|
|
|
|
|
|
|
|
|
| Recent downloads |
|
|
|
|
|
|
|
|
|
|
|
| Github stars |
|
|
|
|
|
|
|
|
|
|
|
| Contributors |
|
|
|
|
|
|
|
|
|
|
|
| Activity |
|
|
|
|
|
|
|
|
|
|
|
| Base framework | hyper / warp | tokio | hyper | hyper | hyper | hyper | tiny-http | tokio | hyper | hyper | hyper |
| https | Y | Y | Y | ? | ? | ? | ? | ? | ? | ? | Y |
| http 2 | Y | Y | ? | ? | ? | ? | ? | ? | ? | ? | Y |
| async | Y | Y | Y | | | | | Y | Y | Y | Y (via different method) |
| stable rust | Y | Y | Y | Y | Y | | Y | Y | Y | Y | Y |
| openapi support | Y | | | | | | | | | | |