82 releases (41 stable)

new 2.8.1 Jan 12, 2021
2.8.0 Nov 13, 2020
2.7.6 Sep 18, 2020
2.7.1 Jul 13, 2020
0.5.2 Jul 16, 2018

#26 in HTTP server

Download history 126/week @ 2020-09-27 104/week @ 2020-10-04 152/week @ 2020-10-11 199/week @ 2020-10-18 105/week @ 2020-10-25 100/week @ 2020-11-01 162/week @ 2020-11-08 175/week @ 2020-11-15 166/week @ 2020-11-22 69/week @ 2020-11-29 137/week @ 2020-12-06 43/week @ 2020-12-13 33/week @ 2020-12-20 11/week @ 2020-12-27 227/week @ 2021-01-03 151/week @ 2021-01-10

519 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
~284K SLoC