1
0
mirror of https://github.com/actix/actix-website synced 2025-03-02 15:23:38 +01:00

38 lines
840 B
Rust
Raw Normal View History

2022-02-26 05:22:21 +00:00
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()
}
2019-06-13 17:10:51 -04:00
// <keep-alive>
2022-02-26 05:22:21 +00:00
use actix_web::{http::KeepAlive, HttpServer};
use std::time::Duration;
2019-06-13 17:10:51 -04:00
2020-09-12 16:21:54 +01:00
#[actix_web::main]
2019-12-29 03:32:56 +09:00
async fn main() -> std::io::Result<()> {
2022-02-26 05:22:21 +00:00
// Set keep-alive to 75 seconds
let _one = HttpServer::new(app).keep_alive(Duration::from_secs(75));
2019-06-13 17:10:51 -04:00
2022-02-26 05:22:21 +00:00
// Use OS's keep-alive (usually quite long)
let _two = HttpServer::new(app).keep_alive(KeepAlive::Os);
2019-06-13 17:10:51 -04:00
2022-02-26 05:22:21 +00:00
// Disable keep-alive
let _three = HttpServer::new(app).keep_alive(None);
2022-02-26 05:22:21 +00:00
Ok(())
2019-06-13 17:10:51 -04:00
}
// </keep-alive>