feather/internals/
runtime_extensions.rs1use feather_runtime::http::Response;
2
3pub trait Finalizer {
6 fn finish_text(&mut self, text: impl Into<String>) -> crate::Outcome;
8 fn finish_html(&mut self, data: impl Into<String>) -> crate::Outcome;
10 fn finish_bytes(&mut self, data: impl Into<Vec<u8>>) -> crate::Outcome;
12 #[cfg(feature = "json")]
13 fn finish_json<T: serde::Serialize>(&mut self, data: &T) -> crate::Outcome;
15}
16
17impl Finalizer for Response {
18 fn finish_text(&mut self, text: impl Into<String>) -> crate::Outcome {
19 self.send_text(text);
20 Ok(crate::middlewares::MiddlewareResult::End)
21 }
22
23 fn finish_html(&mut self, data: impl Into<String>) -> crate::Outcome {
24 self.send_html(data);
25 Ok(crate::middlewares::MiddlewareResult::End)
26 }
27
28 fn finish_bytes(&mut self, data: impl Into<Vec<u8>>) -> crate::Outcome {
29 self.send_bytes(data);
30 Ok(crate::middlewares::MiddlewareResult::End)
31 }
32
33 #[cfg(feature = "json")]
34 fn finish_json<T: serde::Serialize>(&mut self, data: &T) -> crate::Outcome {
35 self.send_json(data);
36 Ok(crate::middlewares::MiddlewareResult::End)
37 }
38}