sailfish-web 0.2.0

Simple extension crate that enables a simpler api for web server crates
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use sailfish::TemplateSimple;
use sailfish_web::web_servers_support::template::TemplateWrapper;
use warp::Filter;
#[derive(Debug, TemplateSimple)]
#[template(path = "test.stpl")]
struct TestTemplate<'a> {
    s: &'a str,
}

#[tokio::main]
async fn main() {
    let hello = warp::path!("hello" / String)
        // Sadly implementing .into() or .from() needs a huge name annotation, so this is the best alternative
        .map(|name: String| TemplateWrapper::from(TestTemplate { s: &name }).into_resp());

    warp::serve(hello).run(([127, 0, 0, 1], 3030)).await;
}