mirror of
https://github.com/actix/actix-website
synced 2025-01-22 16:15:56 +01:00
38 lines
840 B
Rust
38 lines
840 B
Rust
use actix_web::{
|
|
body::MessageBody,
|
|
dev::{ServiceFactory, ServiceRequest, ServiceResponse},
|
|
App, Error,
|
|
};
|
|
|
|
#[allow(dead_code)]
|
|
fn app() -> App<
|
|
impl ServiceFactory<
|
|
ServiceRequest,
|
|
Response = ServiceResponse<impl MessageBody>,
|
|
Config = (),
|
|
InitError = (),
|
|
Error = Error,
|
|
>,
|
|
> {
|
|
App::new()
|
|
}
|
|
|
|
// <keep-alive>
|
|
use actix_web::{http::KeepAlive, HttpServer};
|
|
use std::time::Duration;
|
|
|
|
#[actix_web::main]
|
|
async fn main() -> std::io::Result<()> {
|
|
// Set keep-alive to 75 seconds
|
|
let _one = HttpServer::new(app).keep_alive(Duration::from_secs(75));
|
|
|
|
// Use OS's keep-alive (usually quite long)
|
|
let _two = HttpServer::new(app).keep_alive(KeepAlive::Os);
|
|
|
|
// Disable keep-alive
|
|
let _three = HttpServer::new(app).keep_alive(None);
|
|
|
|
Ok(())
|
|
}
|
|
// </keep-alive>
|