g_server/http/
response.rs1use super::{body::Body, header::Header, status::Status};
2
3#[derive(Debug)]
5pub struct Response {
6 status: Status,
7 headers: Header,
8 body: Body,
9}
10
11impl Response {
12 pub fn new(status: impl Into<Status>, headers: Header, body: impl Into<Body>) -> Self {
14 Self {
15 status: status.into(),
16 headers,
17 body: body.into(),
18 }
19 }
20
21 pub fn status(&self) -> &Status {
23 &self.status
24 }
25
26 pub fn headers(&self) -> &Header {
28 &self.headers
29 }
30
31 pub fn body(&self) -> &Body {
33 &self.body
34 }
35
36 pub fn status_mut(&mut self) -> &mut Status {
38 &mut self.status
39 }
40
41 pub fn headers_mut(&mut self) -> &mut Header {
43 &mut self.headers
44 }
45
46 pub fn body_mut(&mut self) -> &mut Body {
48 &mut self.body
49 }
50
51 pub fn into_body(self) -> Body {
53 self.body
54 }
55
56 pub fn into_parts(self) -> (Status, Header, Body) {
58 (self.status, self.headers, self.body)
59 }
60}