Last active
August 27, 2020 06:46
-
-
Save 12101111/53b54f9756b91e0a09d025a381358632 to your computer and use it in GitHub Desktop.
rustfmt can't format it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use warp::{reject::Rejection, Filter}; | |
#[tokio::main] | |
async fn main() { | |
let echo = warp::get().and(warp::path::param()) | |
.and_then( | |
|path: String| async move { | |
let body = format!(r##"<!DOCTYPE html><html><head><meta charset="utf-8"><title>{}</title></head><body>Echo: {}</body></html>"##, path,path); | |
Ok::<_ ,Rejection>( warp::reply::html(body)) | |
}, | |
); | |
warp::serve(echo).run(([0, 0, 0, 0], 8080)).await; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment