Add proper path parsing, add echo

Change-Id: I70ada04843601976db44d530734bb7071a4d82fa
Reviewed-on: https://git.clicks.codes/c/Clicks/BYO/HttpServer/rust/+/251
Tested-by: Skyler Grey <minion@clicks.codes>
Reviewed-by: Samuel Shuert <coded@clicks.codes>
diff --git a/src/main.rs b/src/main.rs
index d9d8c22..26d1433 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,5 +1,7 @@
 use std::{net::TcpListener, io::{Write, Read}};
 
+use itertools::Itertools;
+
 fn main() {
     let listener = TcpListener::bind("127.0.0.1:4221").unwrap();
 
@@ -30,9 +32,11 @@
                 let unparsed_path = request[1].iter().collect::<String>();
                 let mut path = unparsed_path.split("/");
 
-                let response_status: &str;
+                let response_status: String;
                 let mut response_headers: Vec<String> = vec![];
-                let response_body: &str;
+                let response_body: String;
+
+                // println!("{:?}", path);
 
                 // println!("{:?}", path);
 
@@ -40,18 +44,18 @@
 
                 match path.next().unwrap() {
                     "" => {
-                        response_status = "200 OK";
-                        response_body = "";
+                        response_status = "200 OK".to_owned();
+                        response_body = "".to_owned();
                     },
                     "echo" => {
-                        response_status = "200 OK";
-                        response_body = path.next().unwrap();
+                        response_status = "200 OK".to_owned();
+                        response_body = path.join("/");
                         response_headers.push("Content-Type: text/plain".to_owned());
                         response_headers.push(format!("Content-Length: {}", response_body.len()));
                     },
                     _ => {
-                        response_status = "404 Not Found";
-                        response_body = "";
+                        response_status = "404 Not Found".to_owned();
+                        response_body = "".to_owned();
                     }
                 }