chiark / gitweb /
server: wip, handle GET
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 8 Aug 2021 16:52:15 +0000 (17:52 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 8 Aug 2021 16:52:26 +0000 (17:52 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/bin/server.rs
src/prelude.rs

index 816ae0ce835c4ce921808432e9a8e32b6f250521..8446dd3b1b13c5e680a46d3cf1f223ea4df6cd45 100644 (file)
@@ -20,6 +20,15 @@ async fn handle(
 //    addr: SocketAddr,
     req: hyper::Request<hyper::Body>
 ) -> Result<hyper::Response<hyper::Body>, 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 {
index f3d823c09a50be7635c72b74e370b1679d961717..f44acbdf85d3773558f2eacbfa5b67ad9c653a24 100644 (file)
@@ -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};