From a66b39d6b20b2f6e923075e029a6247ad3acf9bb Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 8 Aug 2021 17:52:15 +0100 Subject: [PATCH] server: wip, handle GET Signed-off-by: Ian Jackson --- src/bin/server.rs | 9 +++++++++ src/prelude.rs | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) 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}; -- 2.30.2