1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use aws_lambda_runtime_proxy::Proxy;
use std::process::Stdio;

#[tokio::main]
async fn main() {
  let mut handler = Proxy::default_command()
    // capture stdout
    .stdout(Stdio::piped())
    // override environment variables for the handler process
    .env("KEY", "VALUE")
    // pass additional arguments to the handler process
    .arg("--help")
    .spawn()
    .unwrap();

  // take the stdout
  let _stdout = handler.stdout.take().unwrap();
  // do something with the stdout

  // wait until the handler process exits
  handler.wait().await.unwrap();
}