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
impl ApiLambda
Sourcepub fn with_op_filter<F>(self, op_filter: F) -> Self
pub fn with_op_filter<F>(self, op_filter: F) -> Self
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 returnstrue
orfalse
to indicate whether the given OpenAPIOperation
(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§
impl Freeze for ApiLambda
impl !RefUnwindSafe for ApiLambda
impl !Send for ApiLambda
impl !Sync for ApiLambda
impl Unpin for ApiLambda
impl !UnwindSafe for ApiLambda
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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