saphir_macro

Crates.iosaphir_macro
lib.rssaphir_macro
version2.2.0
sourcesrc
created_at2020-02-28 02:51:12.885945
updated_at2023-01-09 13:19:09.656634
descriptionMacro generation for http server framework
homepagehttps://github.com/richerarc/saphir
repositoryhttps://github.com/richerarc/saphir
max_upload_size
id213409
size81,371
Richer Archambault (richerarc)

documentation

https://docs.rs/saphir

README

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
}
Commit count: 290

cargo fmt