zero4rs 2.0.0

zero4rs is a powerful, pragmatic, and extremely fast web framework for Rust
Documentation
use actix_web::body::MessageBody;
use actix_web::dev::{ServiceRequest, ServiceResponse};
use actix_web::http::header;
use actix_web::middleware::Next;

pub async fn force_keep_alive(
    req: ServiceRequest,
    next: Next<impl MessageBody>,
) -> Result<ServiceResponse<impl MessageBody>, actix_web::Error> {
    // 调用下一个中间件或处理器
    let mut res = next.call(req).await?;

    // 添加 Connection 和 Keep-Alive 头
    res.headers_mut().insert(
        header::CONNECTION,
        header::HeaderValue::from_static("keep-alive"),
    );

    res.headers_mut().insert(
        header::HeaderName::from_static("keep-alive"),
        header::HeaderValue::from_static("timeout=60, max=100"),
    );

    Ok(res)
}