Struct ApiLambda

Source
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

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

Source§

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

Source§

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.