use crate::api::*; use hyper::{Request, Response}; pub type Req = Request; pub type Res = Response; pub type Ret = Result; #[derive(Debug, Clone)] pub struct Params { // empty for now } #[derive(Debug, Clone)] pub struct Reply { pub buckets: Vec, pub is_truncated: bool, pub next_marker: String, pub owner: UserInfo, } impl ReqParser for Req { /// Request Syntax: /// ``` /// GET / HTTP/1.1 /// ``` fn parse(req: HttpRequest, _bucket: &str, _key: &str) -> Self { let (parts, _) = req.into_parts(); let params = Params {}; Request::from_parts(parts, params) } } impl ResWriter for Res { /// Response Syntax: /// ``` /// HTTP/1.1 200 /// /// /// /// /// timestamp /// string /// /// /// /// string /// string /// /// /// ``` fn write(self) -> HttpResponse { let (parts, r) = self.into_parts(); let mut w = BodyWriter::new_xml(); w.append(""); w.append(""); for b in r.buckets { w.append(""); w.append_xml("Name", b.name.as_str()); w.append_xml("CreationDate", "2021-09-19T00:00:00.000Z"); w.append(""); } w.append(""); w.append(""); w.append_xml("ID", r.owner.id.as_str()); w.append_xml("DisplayName", r.owner.display_name.as_str()); w.append(""); w.append(""); Response::from_parts(parts, w.body()) } }