feat: allow setting http response header in fullstack
This commit is contained in:
1 parent
0aa7351473
commit
20fa29ac6e
3 files changed
+38
-5
No files matched your search
@@ -304,15 +304,23 @@ impl RenderHandleState {
|
||||
.await;
|
||||
|
||||
match response {
|
||||
Ok((status, freshness, rx)) => {
|
||||
Ok((status, headers, freshness, rx)) => {
|
||||
let mut response = Response::builder()
|
||||
.status(status.status)
|
||||
.header(CONTENT_TYPE, "text/html; charset=utf-8")
|
||||
.body(Body::from_stream(rx))
|
||||
.unwrap();
|
||||
|
||||
// Write our freshness header
|
||||
freshness.write(response.headers_mut());
|
||||
|
||||
// write the other headers set by the user
|
||||
for (key, value) in headers.into_iter() {
|
||||
if let Some(key) = key {
|
||||
response.headers_mut().insert(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
response
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user