diff options
author | Tyler Murphy <tylerm@tylerm.dev> | 2023-07-02 22:15:24 -0400 |
---|---|---|
committer | Tyler Murphy <tylerm@tylerm.dev> | 2023-07-02 22:15:24 -0400 |
commit | 41fe16978ea506127bf43c21e977fd9581d87282 (patch) | |
tree | b5bf1ef7a37404350d45f0b6e8a00c5b32216e08 /src/http/response.rs | |
parent | more info (diff) | |
download | bashttp-41fe16978ea506127bf43c21e977fd9581d87282.tar.gz bashttp-41fe16978ea506127bf43c21e977fd9581d87282.tar.bz2 bashttp-41fe16978ea506127bf43c21e977fd9581d87282.zip |
add methods to routes, allow custom headers and response codes
Diffstat (limited to 'src/http/response.rs')
-rw-r--r-- | src/http/response.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/http/response.rs b/src/http/response.rs index 850f41e..85430a4 100644 --- a/src/http/response.rs +++ b/src/http/response.rs @@ -1,8 +1,8 @@ -use super::{code::Code, header::{HeaderMap, Header}}; +use super::{header::{HeaderMap, Header}}; #[derive(Debug, Clone)] pub struct Response { - pub status: Code, + pub status: u16, pub headers: HeaderMap, pub body: Option<String> } @@ -20,7 +20,7 @@ impl Response { headers.put(Header::new("Server", "bashttp")); return Self { - status: Code::Success, + status: 200, headers, body: None } @@ -29,7 +29,7 @@ impl Response { pub fn deserialize(&self) -> String { let mut string = String::new(); - string += &format!("HTTP/1.1 {}\n", self.status.clone() as u16); + string += &format!("HTTP/1.1 {}\n", self.status); string += &self.headers.deserialize(); if let Some(body) = &self.body { |