MCPcopy Create free account
hub / github.com/cargo-lambda/cargo-lambda / proxy

Function proxy

crates/cargo-lambda-watch/src/lib.rs:369–391  ·  view source on GitHub ↗
(
    connection_tracker: TaskTracker,
    req: Request<Incoming>,
    addr: Arc<SocketAddr>,
)

Source from the content-addressed store, hash-verified

367}
368
369async fn proxy(
370 connection_tracker: TaskTracker,
371 req: Request<Incoming>,
372 addr: Arc<SocketAddr>,
373) -> Result<Response<BoxBody<Bytes, hyper::Error>>, hyper::Error> {
374 let stream = TcpStream::connect(&*addr).await.unwrap();
375 let io = TokioIo::new(stream);
376
377 let (mut sender, conn) = http1::Builder::new()
378 .preserve_header_case(true)
379 .title_case_headers(true)
380 .handshake(io)
381 .await?;
382
383 connection_tracker.spawn(async move {
384 if let Err(err) = conn.await {
385 println!("Connection failed: {err:?}");
386 }
387 });
388
389 let resp = sender.send_request(req).await?;
390 Ok(resp.map(|b| b.boxed()))
391}

Callers 1

start_tls_proxyFunction · 0.85

Calls 1

newFunction · 0.85

Tested by

no test coverage detected