1
0
mirror of https://github.com/actix/actix-website synced 2024-12-18 18:03:12 +01:00
actix-website/examples/server/src/keep_alive_tp.rs
Jonas Fassbender 04f6f0bd02
Fixed keep-alive on response example (#316)
* fixed keep-alive on response example

* fixed dead code and unused variable errors
2023-03-03 15:07:26 +00:00

21 lines
508 B
Rust

#![allow(dead_code)]
// <example>
use actix_web::{http, HttpRequest, HttpResponse};
async fn index(_req: HttpRequest) -> HttpResponse {
let mut resp = HttpResponse::Ok()
.force_close() // <- Close connection on HttpResponseBuilder
.finish();
// Alternatively close connection on the HttpResponse struct
resp.head_mut().set_connection_type(http::ConnectionType::Close);
resp
}
// </example>
// ConnectionType::Close
// ConnectionType::KeepAlive
// ConnectionType::Upgrade