1use actix_web::{
4 HttpResponse,
5 http::{StatusCode, header::HeaderName},
6};
7
8pub trait Next {
14 fn next(&self, res: &HttpResponse) -> bool;
15}
16
17pub struct IsStatus(pub StatusCode);
21
22impl IsStatus {
23 pub fn new(status: StatusCode) -> Self {
24 Self(status)
25 }
26}
27
28impl From<StatusCode> for IsStatus {
29 #[inline]
30 fn from(value: StatusCode) -> Self {
31 Self::new(value)
32 }
33}
34
35impl Next for IsStatus {
36 #[inline]
37 fn next(&self, res: &HttpResponse) -> bool {
38 res.status() == self.0
39 }
40}
41
42pub struct HasHeader(pub HeaderName);
47
48impl HasHeader {
49 pub fn new(name: HeaderName) -> Self {
50 Self(name)
51 }
52}
53
54impl From<HeaderName> for HasHeader {
55 #[inline]
56 fn from(value: HeaderName) -> Self {
57 Self::new(value)
58 }
59}
60
61impl Next for HasHeader {
62 #[inline]
63 fn next(&self, res: &HttpResponse) -> bool {
64 res.headers().contains_key(&self.0)
65 }
66}