1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//! This module define the catcher API for Deboa.
//!
//! Catchers are called when an error occurs during request execution.
//! They can be used to implement logic, such as logging, inject headers, etc.
//!
//! # Examples
//!
//! ```rust
//! use deboa::{Result, catcher::DeboaCatcher, request::DeboaRequest, response::DeboaResponse};
//!
//! struct TestMonitor;
//!
//! #[deboa::async_trait]
//! impl DeboaCatcher for TestMonitor {
//! async fn on_request(&self, request: &mut DeboaRequest) -> Result<Option<DeboaResponse>> {
//! println!("Request: {:?}", request.url());
//! Ok(None)
//! }
//!
//! async fn on_response(&self, response: &mut DeboaResponse) -> Result<()> {
//! println!("Response: {:?}", response.status());
//! Ok(())
//! }
//! }
//!
//! // Create a client with middleware
//! let client = deboa::Deboa::builder()
//! .catch(TestMonitor)
//! .build();
//! ```
//!
use async_trait;
use automock;
use crate::;
/// DeboaCatcher
///
/// Trait that define the middleware pattern for Deboa. Keep in mind that
/// It is called before the request is sent and after the response is received.
/// Use it with caution and keep number of catchers low for better performance.
///