actix-web 4.16.0

Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust
Documentation
#[expect(deprecated, reason = "preserve the public ready future type")]
use actix_utils::future::ready;

use crate::{
    body::BoxBody,
    dev::{fn_service, Service, ServiceRequest, ServiceResponse},
    http::StatusCode,
    Error, HttpResponseBuilder,
};

/// Creates service that always responds with `200 OK` and no body.
pub fn ok_service(
) -> impl Service<ServiceRequest, Response = ServiceResponse<BoxBody>, Error = Error> {
    status_service(StatusCode::OK)
}

/// Creates service that always responds with given status code and no body.
#[expect(deprecated, reason = "preserve the public ready future type")]
pub fn status_service(
    status_code: StatusCode,
) -> impl Service<ServiceRequest, Response = ServiceResponse<BoxBody>, Error = Error> {
    fn_service(move |req: ServiceRequest| {
        ready(Ok(req.into_response(
            HttpResponseBuilder::new(status_code).finish(),
        )))
    })
}

#[doc(hidden)]
#[deprecated(since = "4.0.0", note = "Renamed to `status_service`.")]
pub fn simple_service(
    status_code: StatusCode,
) -> impl Service<ServiceRequest, Response = ServiceResponse<BoxBody>, Error = Error> {
    status_service(status_code)
}

#[doc(hidden)]
#[deprecated(since = "4.0.0", note = "Renamed to `status_service`.")]
pub fn default_service(
    status_code: StatusCode,
) -> impl Service<ServiceRequest, Response = ServiceResponse<BoxBody>, Error = Error> {
    status_service(status_code)
}