faithea 0.1.9

A HTTP framework
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use http::header::{CACHE_CONTROL, CONTENT_TYPE};

use crate::response::{HttpResponseModifier, HttpResponseModifierFuture};

pub struct SSE;
impl HttpResponseModifier for SSE {
    fn modify<'a>(
        &'a mut self,
        res: &'a mut super::HttpResponse,
    ) -> HttpResponseModifierFuture<'a> {
        Box::pin(async move {
            res.add_header(CONTENT_TYPE, "text/event-stream".try_into()?);
            res.add_header(CACHE_CONTROL, "no-cache".try_into()?);
            Ok(())
        })
    }
}