1#![forbid(unsafe_code)]
7
8pub mod body;
9pub mod ca;
10pub mod error;
11pub mod event;
12pub(crate) mod handler;
13pub mod intercept;
14pub mod proxy;
15mod rewind;
16#[cfg(feature = "scripting")]
17pub mod scripting;
18
19use body::ProxyBody;
20use hyper::{Request, Response};
21use std::net::SocketAddr;
22
23pub use error::Error;
24pub use event::ProxyEvent;
25pub use handler::CapturingHandler;
26pub use intercept::{InterceptConfig, InterceptDecision};
27pub use proxy::{Proxy, ProxyConfig, ProxyMode};
28
29pub enum RequestOrResponse {
31 Request(Request<ProxyBody>),
32 Response(Response<ProxyBody>),
33}
34
35#[derive(Clone, Debug, Eq, Hash, PartialEq)]
37pub struct HttpContext {
38 pub remote_addr: SocketAddr,
39}
40
41#[async_trait::async_trait]
46pub trait HttpHandler: Clone + Send + Sync + 'static {
47 async fn handle_request(
48 &mut self,
49 ctx: &HttpContext,
50 req: Request<hyper::body::Incoming>,
51 ) -> RequestOrResponse;
52
53 async fn handle_response(
54 &mut self,
55 ctx: &HttpContext,
56 res: Response<hyper::body::Incoming>,
57 ) -> Response<ProxyBody>;
58}