Giter Club home page Giter Club logo

rweb's Introduction

rweb

Build Status

Yet another web server framework for rust.

Installation (without automatic openapi generation):

[dependencies]
rweb = "0.5"
tokio = "0.2"

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>> {
    panic!() // This returns 200 with application/json
}

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

#[get("/product")]
fn new_product(_product: Json<Product>) -> Json<Product> {
    panic!() // 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>> {
    panic!() // 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.

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

rweb's People

Contributors

0x003e avatar celeo avatar dwarn-axiallon avatar kdy1 avatar muqito avatar nullx76 avatar vn971 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.