progress
This commit is contained in:
@@ -7,7 +7,7 @@ use anyhow::Result;
|
||||
use http_body_util::Full;
|
||||
use hyper::body::Incoming;
|
||||
use hyper::service::service_fn;
|
||||
use hyper::{Request, Response};
|
||||
use hyper::{Request, Response, Uri};
|
||||
use macro_rules_attribute::apply;
|
||||
use smol::{future, io, prelude::*, Async, Executor};
|
||||
use smol_hyper::rt::{FuturesIo, SmolTimer};
|
||||
@@ -16,7 +16,12 @@ use smol_macros::main;
|
||||
/// Serves a request and returns a response.
|
||||
async fn serve(req: Request<Incoming>) -> Result<Response<Full<&'static [u8]>>> {
|
||||
println!("Serving {}", req.uri());
|
||||
Ok(Response::new(Full::new("Hello from hyper!".as_bytes())))
|
||||
let path = req.uri().path();
|
||||
let reply = match path {
|
||||
"/" => "mreow",
|
||||
_ => "Invalid path!",
|
||||
};
|
||||
Ok(Response::new(Full::new(reply.as_bytes())))
|
||||
}
|
||||
|
||||
/// Handle a new client.
|
||||
|
||||
Reference in New Issue
Block a user