86 releases (45 stable)

3.1.1 Apr 18, 2023
3.1.0 Jan 9, 2023
3.0.0 Dec 14, 2021
2.8.2 Feb 24, 2021
0.5.2 Jul 16, 2018

#143 in HTTP server

Download history 10/week @ 2024-02-22 16/week @ 2024-02-29 131/week @ 2024-03-07 1/week @ 2024-03-14 272/week @ 2024-03-28

404 downloads per month
Used in 2 crates

MIT license

275KB
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

~8–24MB
~389K SLoC