• Stars
    star
    347
  • Rank 122,141 (Top 3 %)
  • Language
    Rust
  • License
    Apache License 2.0
  • Created almost 5 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Yet another web server framework for rust

rweb

Build Status

Yet another web server framework for rust.

Installation:

[dependencies]
rweb = "0.6"
tokio = "1"

Installation (with automatic openapi generation):

[dependencies]
rweb = { version = "0.6", features = ["openapi"] }
serde = "1"
tokio = "1"

Features

  • Safe & Correct

Since rweb is based on warp, which features safety and correctness, rweb has same property.

  • Easy to read code
use rweb::*;
use serde::{Serialize, Deserialize};

#[get("/output")]
fn output() -> String {
    String::from("this returns 200 with text/plain mime type")
}

#[derive(Debug, Serialize, Deserialize, Schema)]
struct Product {
    id: String,
    title: String,
}

#[get("/products")]
fn products() -> Json<Vec<Product>> {
    // ...
    // This returns 200 with application/json
}

#[get("/products/{id}")]
fn product(id: String) -> Json<Product> {
    // ...
    // This returns 200 with application/json
}

#[get("/product")]
fn new_product(_product: Json<Product>) -> Json<Product> {
    // ...
    // This returns 200 with application/json
}

#[derive(Debug, Serialize, Deserialize, Schema)]
struct SearchOption {
    query: String,
    limit: usize,
    page_token: String,
}

#[get("/search")]
fn search(_product: Query<SearchOption>) -> Json<Vec<Product>> {
    // ...
    // This returns 200 with application/json
}

#[tokio::main]
async fn main() {
    serve(output().or(product()).or(products()).or(search())).run(([127, 0, 0, 1], 3030)).await;
}
  • Websocket

If you want to use websocket, just declare a parameter typed Ws. It's all.

use rweb::*;

#[get("/ws")]
fn example(ws: ws::Ws) -> String {
    String::new("use ws.on_upgrade or extra")
}
  • Automatic openapi spec generation

rweb supports automatically generating openapi specification file based on your code.

See: documentation for usage.

  • API UX interaction for openapi
// Build openapi for your API
let (spec, filter) = openapi::spec().build(move || {
    // Your API's filters
    math::math()
        .or(products::products())
        .or(generic::body())
        .or(generic::optional())
        .or(generic::search())
        .or(response::response())
});

println!("go to http://localhost:3030/docs to interact with your openapi!");
serve(filter.or(openapi_docs(spec)))
    .run(([127, 0, 0, 1], 3030))
    .await;

Comparison

Name rweb actix-web gotham iron nickel rocket rouille Thruster Tide tower-web warp
License license license license license license license license license license license license
Version version version version version version version version version version version version
Recent downloads recent downloads recent downloads recent downloads recent downloads recent downloads recent downloads recent downloads recent downloads recent downloads recent downloads recent downloads
Github stars github stars github stars github stars github stars github stars github stars github stars github stars github stars github stars github stars
Contributors contributors contributors contributors contributors contributors contributors contributors contributors contributors contributors contributors
Activity activity activity activity activity activity activity activity activity activity activity 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

More Repositories

1

cargo-profile

Merged into https://github.com/dudykr/ddt
Rust
89
star
2

benchmark-done-right

Fair benchmark for js tools.
TypeScript
57
star
3

devmap

개발자용 로드맵
JavaScript
56
star
4

cargo-mono

Monolithic repository management for the rust programming language.
Rust
34
star
5

is-macro

Moved to https://github.com/dudykr/ddbase
Rust
16
star
6

ask-me-anything

Ask me anything
13
star
7

typed_firestore

Typed firstore for flutter
Dart
11
star
8

rust-pmutil

Rust
10
star
9

dbg-swc

CLI tool to debug swc
Rust
9
star
10

guard_let

Rust
7
star
11

react-forms

Smart validation for react
TypeScript
5
star
12

web-utils

Web-based utilities to aid swc development
TypeScript
5
star
13

wasm-perf

Rust
5
star
14

pure_firestore

Dart
4
star
15

swc-ts-stack-checker

Gtihub crawler to find code causing stack overflow
Rust
3
star
16

flatten

Tuple flattening for rust-lang.
Rust
3
star
17

fiber

Go
3
star
18

rust-static-map

Moved to https://github.com/dudykr/ddbase
Rust
3
star
19

flutter_open_notification_settings

A plugin to open notification settings
Java
3
star
20

rust-caniuse

caniuse-db for rust.
Rust
3
star
21

neon-worker-thread

Rust
2
star
22

turbo-windows-path-length

Rust
2
star
23

next-swc-minify-firebase-9

CSS
2
star
24

gzipped

Gzipped files
2
star
25

next-swc-es5-repro

JavaScript
1
star
26

swc-example

JavaScript
1
star
27

rust-dylib-test

Test for rust-based plugin system for swc
Rust
1
star
28

comit-typescript-react-study

TypeScript
1
star
29

crev-proofs

1
star
30

go-lol

Go
1
star
31

blog-comments

1
star
32

xui

Rust
1
star
33

spack-perf

I need flamegraph
Rust
1
star
34

var_widget

A new state management for flutter
Dart
1
star
35

typed_fb_data

Dart
1
star
36

kdy1

1
star
37

repro-next-minify-module

CSS
1
star
38

repro-swc-8789

swc-issues
JavaScript
1
star