Skip to content

Instantly share code, notes, and snippets.

@12101111
Last active August 27, 2020 06:46
Show Gist options
  • Save 12101111/53b54f9756b91e0a09d025a381358632 to your computer and use it in GitHub Desktop.
Save 12101111/53b54f9756b91e0a09d025a381358632 to your computer and use it in GitHub Desktop.
rustfmt can't format it
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