83 releases (42 stable)

2.8.2 Feb 24, 2021
2.8.0 Nov 13, 2020
2.7.1 Jul 13, 2020
2.2.4 Mar 31, 2020
0.5.2 Jul 16, 2018

#67 in Web programming

Download history 216/week @ 2021-01-15 78/week @ 2021-01-22 71/week @ 2021-01-29 101/week @ 2021-02-05 461/week @ 2021-02-12 190/week @ 2021-02-19 121/week @ 2021-02-26 107/week @ 2021-03-05 134/week @ 2021-03-12 223/week @ 2021-03-19 191/week @ 2021-03-26 232/week @ 2021-04-02 117/week @ 2021-04-09 437/week @ 2021-04-16 87/week @ 2021-04-23 160/week @ 2021-04-30

609 downloads per month
Used in slauth

MIT license

270KB
6.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

~8–14MB
~290K SLoC