actix / actix-extras
Showing 1 of 2 files from the diff.
Other files ignored by Codecov

@@ -1,6 +1,9 @@
Loading
1 -
use std::{collections::HashSet, convert::TryInto, iter::FromIterator, rc::Rc};
1 +
use std::{
2 +
    collections::HashSet, convert::TryInto, error::Error as StdError, iter::FromIterator, rc::Rc,
3 +
};
2 4
3 5
use actix_web::{
6 +
    body::MessageBody,
4 7
    dev::{RequestHead, Service, ServiceRequest, ServiceResponse, Transform},
5 8
    error::{Error, Result},
6 9
    http::{self, header::HeaderName, Error as HttpError, HeaderValue, Method, Uri},
@@ -479,10 +482,12 @@
Loading
479 482
    }
480 483
}
481 484
482 -
impl<S> Transform<S, ServiceRequest> for Cors
485 +
impl<S, B> Transform<S, ServiceRequest> for Cors
483 486
where
484 -
    S: Service<ServiceRequest, Response = ServiceResponse, Error = Error>,
487 +
    S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
485 488
    S::Future: 'static,
489 +
    B: MessageBody + 'static,
490 +
    B::Error: StdError,
486 491
{
487 492
    type Response = ServiceResponse;
488 493
    type Error = Error;
@@ -560,11 +565,15 @@
Loading
560 565
#[cfg(test)]
561 566
mod test {
562 567
    use std::convert::{Infallible, TryInto};
568 +
    use std::pin::Pin;
569 +
    use std::task::{Context, Poll};
563 570
564 571
    use actix_web::{
565 -
        dev::Transform,
572 +
        body::{BodySize, MessageBody},
573 +
        dev::{fn_service, Transform},
566 574
        http::{HeaderName, StatusCode},
567 575
        test::{self, TestRequest},
576 +
        web::{Bytes, HttpResponse},
568 577
    };
569 578
570 579
    use super::*;
@@ -616,4 +625,28 @@
Loading
616 625
617 626
        let _cors = Cors::default().allowed_header(ContentType);
618 627
    }
628 +
629 +
    #[actix_rt::test]
630 +
    async fn middleware_generic_over_body_type() {
631 +
        struct Foo;
632 +
633 +
        impl MessageBody for Foo {
634 +
            type Error = std::io::Error;
635 +
            fn size(&self) -> BodySize {
636 +
                BodySize::None
637 +
            }
638 +
            fn poll_next(
639 +
                self: Pin<&mut Self>,
640 +
                _: &mut Context<'_>,
641 +
            ) -> Poll<Option<Result<Bytes, Self::Error>>> {
642 +
                Poll::Ready(None)
643 +
            }
644 +
        }
645 +
646 +
        let srv = fn_service(|req: ServiceRequest| async move {
647 +
            Ok(req.into_response(HttpResponse::Ok().message_body(Foo)?))
648 +
        });
649 +
650 +
        Cors::default().new_transform(srv).await.unwrap();
651 +
    }
619 652
}
Files Coverage
actix-cors/src 86.82%
actix-identity/src 95.97%
actix-redis/src 81.85%
actix-session/src 83.69%
actix-web-httpauth/src 60.42%
actix-protobuf/src/lib.rs 50.46%
Project Totals (30 files) 79.61%
1
comment: false
2

3
coverage:
4
  status:
5
    project:
6
      default:
7
        threshold: 100% # make CI green
8
    patch:
9
      default:
10
        threshold: 100% # make CI green
11

12
# ignore code coverage on following paths
13
ignore:
14
  - "**/tests"
15
  - "**/benches"
16
  - "**/examples"
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading