pub struct ApiLambda { /* private fields */ }
Expand description

Builder for generating code for a single API Lambda function.

An ApiLambda instance represents a collection of API endpoints handled by a single Lambda function. This could include all endpoints defined in an OpenAPI spec (i.e., a “mono-Lambda”), a single API endpoint, or a subset of the API. Larger Lambda binaries incur a greater cold start cost than smaller binaries, so the granularity of API Lambda functions presents a tradeoff between performance and implementation/deployment complexity (i.e., more Lambda functions to manage).

Use the with_op_filter method to specify a closure that associates API endpoints with the corresponding Lambda function.

Example

ApiLambda::new("backend", LambdaArn::cloud_formation("BackendApiFunction.Alias"))

Implementations§

source§

impl ApiLambda

source

pub fn new<M>(mod_name: M, lambda_arn: LambdaArn) -> Self
where M: Into<String>,

Construct a new ApiLambda.

Arguments
  • mod_name - Name of the Rust module to generate (must be a valid Rust identifier)
  • lambda_arn - Amazon Resource Name (ARN) of the AWS Lambda function that will handle requests to the corresponding API endpoints via Amazon API Gateway (see LambdaArn)
source

pub fn with_op_filter<F>(self, op_filter: F) -> Self
where F: Fn(&Operation) -> bool + 'static,

Define a filter to associate a subset of API endpoints with this Lambda function.

Use this method when not implementing a “mono-Lambda” that handles all API endpoints. By default, all API endpoints will be included unless this method is called.

Arguments
  • op_filter - Closure that returns true or false to indicate whether the given OpenAPI Operation (endpoint) will be handled by the corresponding Lambda function
Example
ApiLambda::new("backend", LambdaArn::cloud_formation("BackendApiFunction.Alias"))
  // Only include API endpoints with the `pet` tag.
  .with_op_filter(|op| op.tags.iter().any(|tag| tag == "pet"))

Auto Trait Implementations§

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, 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.