fun_html/interop/
salvo_v074.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use salvo_v074::prelude::*;

impl Scribe for crate::Element {
    fn render(self, res: &mut Response) {
        res.render(Text::Html(self.to_string()));
    }
}

impl Scribe for crate::Document {
    fn render(self, res: &mut Response) {
        res.render(Text::Html(self.to_string()));
    }
}

#[cfg(test)]
mod tests {
    use crate::{elt::div, html};

    use super::*;

    #[test]
    fn document_should_set_content_type() {
        let mut doc_resp = Response::new();
        doc_resp.render(html([], []));
        assert_eq!(
            doc_resp.content_type(),
            Some("text/html; charset=utf-8".parse().unwrap())
        );
    }

    #[test]
    fn element_should_set_content_type() {
        let mut doc_resp = Response::new();
        doc_resp.render(div([], []));
        assert_eq!(
            doc_resp.content_type(),
            Some("text/html; charset=utf-8".parse().unwrap())
        );
    }
}