#![forbid(unsafe_code)]
pub mod body;
pub mod ca;
pub mod error;
pub mod event;
pub(crate) mod handler;
pub mod intercept;
pub mod proxy;
mod rewind;
#[cfg(feature = "scripting")]
pub mod scripting;
use body::ProxyBody;
use hyper::{Request, Response};
use std::net::SocketAddr;
pub use error::Error;
pub use event::ProxyEvent;
pub use handler::{CapturingHandler, DEFAULT_BODY_CAPTURE_LIMIT};
pub use intercept::{InterceptConfig, InterceptDecision};
pub use proxy::{Proxy, ProxyConfig, ProxyMode};
pub enum RequestOrResponse {
Request(Request<ProxyBody>),
Response(Response<ProxyBody>),
}
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
pub struct HttpContext {
pub remote_addr: SocketAddr,
}
#[async_trait::async_trait]
pub trait HttpHandler: Clone + Send + Sync + 'static {
async fn handle_request(
&mut self,
ctx: &HttpContext,
req: Request<hyper::body::Incoming>,
) -> RequestOrResponse;
async fn handle_response(
&mut self,
ctx: &HttpContext,
res: Response<hyper::body::Incoming>,
) -> Response<ProxyBody>;
}