Struct openapi_lambda_codegen::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
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"))