75 releases (34 stable)

new 2.7.2 Aug 6, 2020
2.7.1 Jul 13, 2020
2.6.10 Jun 30, 2020
2.2.4 Mar 31, 2020
0.5.2 Jul 16, 2018

#9 in HTTP server

Download history 253/week @ 2020-04-19 197/week @ 2020-04-26 162/week @ 2020-05-03 212/week @ 2020-05-10 364/week @ 2020-05-17 182/week @ 2020-05-24 335/week @ 2020-05-31 216/week @ 2020-06-07 193/week @ 2020-06-14 97/week @ 2020-06-21 181/week @ 2020-06-28 221/week @ 2020-07-05 255/week @ 2020-07-12 269/week @ 2020-07-19 151/week @ 2020-07-26 158/week @ 2020-08-02

929 downloads per month
Used in slauth

MIT license

255KB
6K 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

~7–13MB
~282K SLoC