waveless_commons/http_executor/
response_cx.rs1use crate::*;
5
6#[derive(Getters, MutGetters, Default)]
8#[getset(get = "pub", get_mut = "pub")]
9pub struct ResponseCx {
10 status: StatusCode,
11 headers: HashMap<CompactString, CompactString>,
12 body: Option<BodyValue>,
13}
14
15impl ResponseCx {
16 pub fn new(headers: HashMap<CompactString, CompactString>, body: Option<BodyValue>) -> Self {
17 Self {
18 status: StatusCode::OK,
19 headers,
20 body,
21 }
22 }
23
24 pub fn new_with_status(
26 status: StatusCode,
27 headers: HashMap<CompactString, CompactString>,
28 body: Option<BodyValue>,
29 ) -> Self {
30 Self {
31 status,
32 headers,
33 body,
34 }
35 }
36}
37
38pub enum BodyValue {
41 Json(serde_json::Value),
42 Any(Box<dyn Encode<Output = Bytes> + Send + Sync>),
43}