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