67 releases (26 stable)

✓ Uses Rust 2018 edition

2.6.7 May 12, 2020
2.6.2 Apr 30, 2020
2.2.4 Mar 31, 2020
1.0.0 Feb 4, 2020
0.5.2 Jul 16, 2018

#8 in HTTP server

Download history 142/week @ 2020-01-25 145/week @ 2020-02-01 199/week @ 2020-02-08 182/week @ 2020-02-15 542/week @ 2020-02-22 197/week @ 2020-02-29 250/week @ 2020-03-07 369/week @ 2020-03-14 435/week @ 2020-03-21 198/week @ 2020-03-28 242/week @ 2020-04-04 521/week @ 2020-04-11 251/week @ 2020-04-18 195/week @ 2020-04-25 169/week @ 2020-05-02 191/week @ 2020-05-09

1,243 downloads per month
Used in slauth

MIT license

240KB
5.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

~7–12MB
~272K SLoC