1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-06-26 15:07:42 +02:00

move response extensions out of head (#2585)

This commit is contained in:
Rob Ede
2022-01-19 02:09:25 +00:00
committed by GitHub
parent 7b8a392ef5
commit 2ffc21dd4f
21 changed files with 205 additions and 226 deletions

View File

@ -15,6 +15,7 @@ async fn main() -> io::Result<()> {
HttpService::build()
.client_timeout(1000)
.client_disconnect(1000)
// handles HTTP/1.1 and HTTP/2
.finish(|mut req: Request| async move {
let mut body = BytesMut::new();
while let Some(item) = req.payload().next().await {
@ -23,12 +24,13 @@ async fn main() -> io::Result<()> {
log::info!("request body: {:?}", body);
Ok::<_, Error>(
Response::build(StatusCode::OK)
.insert_header(("x-head", HeaderValue::from_static("dummy value!")))
.body(body),
)
let res = Response::build(StatusCode::OK)
.insert_header(("x-head", HeaderValue::from_static("dummy value!")))
.body(body);
Ok::<_, Error>(res)
})
// No TLS
.tcp()
})?
.run()