From: Ian Jackson Date: Sun, 8 Aug 2021 16:52:15 +0000 (+0100) Subject: server: wip, handle GET X-Git-Tag: hippotat/1.0.0~207 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=a66b39d6b20b2f6e923075e029a6247ad3acf9bb;p=hippotat.git server: wip, handle GET Signed-off-by: Ian Jackson --- diff --git a/src/bin/server.rs b/src/bin/server.rs index 816ae0c..8446dd3 100644 --- a/src/bin/server.rs +++ b/src/bin/server.rs @@ -20,6 +20,15 @@ async fn handle( // addr: SocketAddr, req: hyper::Request ) -> Result, Infallible> { + if req.method() == Method::GET { + let mut resp = hyper::Response::new(hyper::Body::from("hippotat\r\n")); + resp.headers_mut().insert( + "Content-Type", + "text/plain; charset=US-ASCII".try_into().unwrap() + ); + return Ok(resp) + } + let mut warnings: Warnings = default(); match async { diff --git a/src/prelude.rs b/src/prelude.rs index f3d823c..f44acbd 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -30,7 +30,7 @@ pub use extend::ext; pub use fehler::{throw, throws}; pub use futures::{poll, future, StreamExt as _}; pub use hyper::body::{Bytes, Buf as _}; -pub use hyper::Uri; +pub use hyper::{Method, Uri}; pub use hyper_tls::HttpsConnector; pub use ipnet::IpNet; pub use itertools::{iproduct, Itertools};