1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-06-27 07:19:04 +02:00

rename simple_service to status_service (#2659)

This commit is contained in:
Rob Ede
2022-02-22 07:06:36 +00:00
committed by GitHub
parent 5aa6f713c7
commit 11bfa84926
5 changed files with 22 additions and 12 deletions

View File

@ -1,6 +1,9 @@
# Changes
## Unreleased - 2021-xx-xx
- Rename `test::{simple_service => status_service}`. [#2659]
[#2659]: https://github.com/actix/actix-web/pull/2659
## 4.0.0-rc.3 - 2022-02-08

View File

@ -191,7 +191,6 @@ mod tests {
StatusCode,
},
test::{self, TestRequest},
ResponseError,
};
#[actix_rt::test]
@ -205,7 +204,7 @@ mod tests {
Ok(ErrorHandlerResponse::Response(res.map_into_left_body()))
}
let srv = test::simple_service(StatusCode::INTERNAL_SERVER_ERROR);
let srv = test::status_service(StatusCode::INTERNAL_SERVER_ERROR);
let mw = ErrorHandlers::new()
.handler(StatusCode::INTERNAL_SERVER_ERROR, error_handler)
@ -232,7 +231,7 @@ mod tests {
))
}
let srv = test::simple_service(StatusCode::INTERNAL_SERVER_ERROR);
let srv = test::status_service(StatusCode::INTERNAL_SERVER_ERROR);
let mw = ErrorHandlers::new()
.handler(StatusCode::INTERNAL_SERVER_ERROR, error_handler)
@ -258,7 +257,7 @@ mod tests {
Ok(ErrorHandlerResponse::Response(res))
}
let srv = test::simple_service(StatusCode::INTERNAL_SERVER_ERROR);
let srv = test::status_service(StatusCode::INTERNAL_SERVER_ERROR);
let mw = ErrorHandlers::new()
.handler(StatusCode::INTERNAL_SERVER_ERROR, error_handler)
@ -279,7 +278,7 @@ mod tests {
))
}
let srv = test::simple_service(StatusCode::BAD_REQUEST);
let srv = test::status_service(StatusCode::BAD_REQUEST);
let mw = ErrorHandlers::new()
.handler(StatusCode::BAD_REQUEST, error_handler)

View File

@ -5,7 +5,7 @@
//!
//! # Off-The-Shelf Test Services
//! - [`ok_service`]
//! - [`simple_service`]
//! - [`status_service`]
//!
//! # Calling Test Service
//! - [`TestRequest`]
@ -27,7 +27,7 @@ mod test_utils;
pub use self::test_request::TestRequest;
#[allow(deprecated)]
pub use self::test_services::{default_service, ok_service, simple_service};
pub use self::test_services::{default_service, ok_service, simple_service, status_service};
#[allow(deprecated)]
pub use self::test_utils::{
call_and_read_body, call_and_read_body_json, call_service, init_service, read_body,

View File

@ -10,11 +10,11 @@ use crate::{
/// Creates service that always responds with `200 OK` and no body.
pub fn ok_service(
) -> impl Service<ServiceRequest, Response = ServiceResponse<BoxBody>, Error = Error> {
simple_service(StatusCode::OK)
status_service(StatusCode::OK)
}
/// Creates service that always responds with given status code and no body.
pub fn simple_service(
pub fn status_service(
status_code: StatusCode,
) -> impl Service<ServiceRequest, Response = ServiceResponse<BoxBody>, Error = Error> {
fn_service(move |req: ServiceRequest| {
@ -23,9 +23,17 @@ pub fn simple_service(
}
#[doc(hidden)]
#[deprecated(since = "4.0.0", note = "Renamed to `simple_service`.")]
#[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> {
simple_service(status_code)
status_service(status_code)
}