15 stable releases

2.1.2 Jan 12, 2021
2.1.1 Aug 6, 2020
2.1.0 Jul 10, 2020
2.0.1 Mar 31, 2020
1.1.0 Mar 18, 2020

#49 in Procedural macros

Download history 202/week @ 2021-01-07 140/week @ 2021-01-14 84/week @ 2021-01-21 70/week @ 2021-01-28 54/week @ 2021-02-04 180/week @ 2021-02-11 117/week @ 2021-02-18 117/week @ 2021-02-25 88/week @ 2021-03-04 119/week @ 2021-03-11 65/week @ 2021-03-18 92/week @ 2021-03-25 79/week @ 2021-04-01 110/week @ 2021-04-08 210/week @ 2021-04-15 77/week @ 2021-04-22

408 downloads per month
Used in saphir

MIT license

72KB
1.5K SLoC

logo

doc crate issue Rust downloads license dependency status

Saphir is a fully async-await http server framework for rust

The goal is to give low-level control to your web stack (as hyper does) without the time consuming task of doing everything from scratch.

Quick Overview

use saphir::prelude::*;
struct TestController {}
#[controller]
impl TestController {
    #[get("/{var}/print")]
    async fn print_test(&self, var: String) -> (u16, String) {
        (200, var)
    }
}
async fn test_handler(mut req: Request) -> (u16, Option<String>) {
    (200, req.captures_mut().remove("variable"))
}
#[tokio::main]
async fn main() -> Result<(), SaphirError> {
    env_logger::init();
    let server = Server::builder()
        .configure_listener(|l| {
            l.interface("127.0.0.1:3000")
        })
        .configure_router(|r| {
            r.route("/{variable}/print", Method::GET, test_handler)
                .controller(TestController {})
        })
        .build();
    
    server.run().await
}

Dependencies

~0.9–1.4MB
~29K SLoC