Skip to content

Commit

Permalink
doc
Browse files Browse the repository at this point in the history
  • Loading branch information
hatoo committed Nov 7, 2024
1 parent 269f003 commit 41623a2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/https.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ async fn main() {
let service = service_fn(move |req| {
let client = client.clone();

MitmProxy::hyper_service(
MitmProxy::wrap_service(
proxy.clone(),
req,
service_fn(move |req| {
Expand Down
7 changes: 4 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ impl<C: Borrow<rcgen::CertifiedKey> + Send + Sync + 'static> MitmProxy<C> {
.serve_connection(
TokioIo::new(stream),
service_fn(|req| {
Self::hyper_service(proxy.clone(), req, service.clone())
Self::wrap_service(proxy.clone(), req, service.clone())
}),
)
.with_upgrades()
Expand All @@ -101,11 +101,12 @@ impl<C: Borrow<rcgen::CertifiedKey> + Send + Sync + 'static> MitmProxy<C> {
})
}

/// A service that can be used with hyper server.
/// Transform a service to a service that can be used in hyper server.
/// URL for requests that passed to service are full URL including scheme.
/// See `examples/https.rs` for usage.
/// If you want to serve simple HTTP proxy server, you can use `bind` method instead.
/// `bind` will call this method internally.
pub async fn hyper_service<S, B, E, E2>(
pub async fn wrap_service<S, B, E, E2>(
proxy: Arc<Self>,
req: Request<Incoming>,
mut service: S,
Expand Down

0 comments on commit 41623a2

Please sign in to comment.