1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-08-29 00:07:48 +02:00

Use immutable reference of service state. Update awc dns resolver. (#1905)

This commit is contained in:
fakeshadow
2021-02-06 17:00:40 -08:00
committed by GitHub
parent 20cf0094e5
commit 41bc04b1c4
65 changed files with 497 additions and 538 deletions

View File

@@ -76,14 +76,14 @@ where
type Error = E::Error;
type Future = Either<E::Future, D::Future>;
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
fn poll_ready(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
match self {
ConditionMiddleware::Enable(service) => service.poll_ready(cx),
ConditionMiddleware::Disable(service) => service.poll_ready(cx),
}
}
fn call(&mut self, req: Req) -> Self::Future {
fn call(&self, req: Req) -> Self::Future {
match self {
ConditionMiddleware::Enable(service) => Either::Left(service.call(req)),
ConditionMiddleware::Disable(service) => Either::Right(service.call(req)),
@@ -123,12 +123,12 @@ mod tests {
let mw =
ErrorHandlers::new().handler(StatusCode::INTERNAL_SERVER_ERROR, render_500);
let mut mw = Condition::new(true, mw)
let mw = Condition::new(true, mw)
.new_transform(srv.into_service())
.await
.unwrap();
let resp =
test::call_service(&mut mw, TestRequest::default().to_srv_request()).await;
test::call_service(&mw, TestRequest::default().to_srv_request()).await;
assert_eq!(resp.headers().get(CONTENT_TYPE).unwrap(), "0001");
}
@@ -141,13 +141,13 @@ mod tests {
let mw =
ErrorHandlers::new().handler(StatusCode::INTERNAL_SERVER_ERROR, render_500);
let mut mw = Condition::new(false, mw)
let mw = Condition::new(false, mw)
.new_transform(srv.into_service())
.await
.unwrap();
let resp =
test::call_service(&mut mw, TestRequest::default().to_srv_request()).await;
test::call_service(&mw, TestRequest::default().to_srv_request()).await;
assert_eq!(resp.headers().get(CONTENT_TYPE), None);
}
}