stage 4 attempt 2
This commit is contained in:
1 parent
5fb0b9478e
commit
a86efcf494
1 file changed
+4
-3
+4
-3
@@ -1,6 +1,6 @@
|
||||
#![feature(if_let_guard)]
|
||||
// #![feature(if_let_guard)]
|
||||
|
||||
use std::{ fmt::Display, io::{ BufRead, BufReader, Write }, net::TcpListener };
|
||||
use std::{ io::{ BufRead, BufReader, Write }, net::TcpListener };
|
||||
use anyhow::Result;
|
||||
use thiserror::Error;
|
||||
|
||||
@@ -38,7 +38,8 @@ fn main() -> Result<()> {
|
||||
|
||||
let response = match path.as_str() {
|
||||
"/" => Response::Empty,
|
||||
p if let Some(echo) = p.strip_prefix("/echo/") => Response::TextPlain(echo),
|
||||
// p if let Some(echo) = p.strip_prefix("/echo/") => Response::TextPlain(echo), // a nicer way to do that, not available in stable yet
|
||||
p if p.starts_with("/echo/") => Response::TextPlain(p.trim_start_matches("/echo/")),
|
||||
_ => Response::_404,
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user