pub struct Proxy {
    pub port: Option<u16>,
    pub command: Option<Command>,
}

Fields§

§port: Option<u16>§command: Option<Command>

Implementations§

source§

impl Proxy

source

pub fn default_command() -> Command

Create the handler command from the argv[1..]. For example if the command of the current process is proxy node --help then the handler command will be node --help. You can modify the handler command and pass it to Self::command.

§Examples
use lambda_runtime_proxy::Proxy;
use std::process::Stdio;

#[tokio::main]
async fn main {
  // retrieve the default handler command
  let mut command = Proxy::default_command();

  // enhance the handler command
  command
    // override environment variables for the handler process
    .env("KEY", "VALUE")
    // pipe the stdout and stderr of the handler process
    .stdout(Stdio::piped())
    .stderr(Stdio::piped());

  Proxy::default()
    .command(command)
    .spawn().await;
}
source

pub fn port(self, port: u16) -> Self

Set the port of the proxy server. If not set, the port will be read from the environment variable AWS_LAMBDA_RUNTIME_PROXY_PORT, or default to 3000.

source

pub fn command(self, cmd: Command) -> Self

Set the command of the handler process. If not set, the command will be created using Self::default_command.

source

pub async fn spawn<ReqBody: Body + Send + 'static>( self ) -> RunningProxy<ReqBody>
where ReqBody::Data: Send, ReqBody::Error: Into<Box<dyn Error + Send + Sync>>,

Spawn the proxy server, lambda runtime api client and the handler process. The handler process will be spawned with the environment variable AWS_LAMBDA_RUNTIME_API set to the address of the proxy server.

Trait Implementations§

source§

impl Default for Proxy

source§

fn default() -> Proxy

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Proxy

§

impl !RefUnwindSafe for Proxy

§

impl Send for Proxy

§

impl Sync for Proxy

§

impl Unpin for Proxy

§

impl !UnwindSafe for Proxy

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more