#hyper #http #server #web #async

macro saphir_macro

Macro generation for http server framework

12 stable releases

✓ Uses Rust 2018 edition

new 2.0.10 Jul 7, 2020
2.0.9 Jul 6, 2020
2.0.8 Jun 30, 2020
2.0.4 May 1, 2020
1.0.0-beta Feb 28, 2020

#258 in HTTP server

Download history 215/week @ 2020-03-16 116/week @ 2020-03-23 137/week @ 2020-03-30 143/week @ 2020-04-06 153/week @ 2020-04-13 184/week @ 2020-04-20 132/week @ 2020-04-27 97/week @ 2020-05-04 174/week @ 2020-05-11 81/week @ 2020-05-18 83/week @ 2020-05-25 150/week @ 2020-06-01 194/week @ 2020-06-08 135/week @ 2020-06-15 95/week @ 2020-06-22 118/week @ 2020-06-29

580 downloads per month
Used in saphir

MIT license

72KB
1.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

~1–1.4MB
~28K SLoC