1use hyper::status::StatusCode;
2use hyper::header::Headers;
3
4pub struct SapperResponse {
6 status: StatusCode,
7 headers: Headers,
8 body: Option<Vec<u8>>,
9}
10
11
12impl SapperResponse {
13 pub fn new() -> SapperResponse {
14 SapperResponse {
15 status: StatusCode::Ok,
16 headers: Headers::new(),
17 body: None
18 }
19 }
20
21 pub fn status(&self) -> StatusCode {
23 self.status
24 }
25
26 pub fn set_status(&mut self, status: StatusCode) {
28 self.status = status;
29 }
30
31
32 pub fn headers(&self) -> &Headers {
34 &self.headers
35 }
36
37 pub fn headers_mut(&mut self) -> &mut Headers {
39 &mut self.headers
40 }
41
42 pub fn body(&self) -> &Option<Vec<u8>>{
44 &self.body
45 }
46
47 pub fn write_body(&mut self, body: String) {
49 self.body = Some(body.as_bytes().to_vec())
50 }
51
52 pub fn write_raw_body(&mut self, body: Vec<u8>) {
54 self.body = Some(body)
55 }
56
57}
58