
org.http4k.serverless.ApiGatewayV2.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of http4k-serverless-lambda Show documentation
Show all versions of http4k-serverless-lambda Show documentation
Http4k Serverless support for AWS Lambda
package org.http4k.serverless
import com.amazonaws.services.lambda.runtime.Context
import org.http4k.base64Encode
import org.http4k.core.HttpHandler
import org.http4k.core.Method
import org.http4k.core.Request
import org.http4k.core.Response
import org.http4k.core.Uri
import org.http4k.core.cookie.Cookie
import org.http4k.core.cookie.cookies
import org.http4k.core.queries
import org.http4k.core.toUrlFormEncoded
import java.util.Locale.getDefault
/**
* Function loader for ApiGatewayV2 Lambdas
*/
class ApiGatewayV2FnLoader(input: AppLoaderWithContexts) : ApiGatewayFnLoader(ApiGatewayV2AwsHttpAdapter, input) {
constructor(input: AppLoader) : this(AppLoaderWithContexts { env, _ -> input(env) })
constructor(input: HttpHandler) : this(AppLoader { input })
}
/**
* This is the main entry point for lambda invocations using the V2 payload format.
* It uses the local environment to instantiate the HttpHandler which can be used
* for further invocations.
*
* Use main constructor if you need to read ENV variables to make your HttpHandler and the AWS context
*/
abstract class ApiGatewayV2LambdaFunction(input: AppLoaderWithContexts) :
AwsLambdaEventFunction(ApiGatewayV2FnLoader(input)) {
/**
* Use this constructor if you need to read ENV variables to make your HttpHandler
*/
constructor(input: AppLoader) : this(AppLoaderWithContexts { env, _ -> input(env) })
/**
* Use this constructor if you just want to convert a standard HttpHandler
*/
constructor(input: HttpHandler) : this(AppLoader { input })
}
object ApiGatewayV2AwsHttpAdapter : AwsHttpAdapter
© 2015 - 2025 Weber Informatics LLC | Privacy Policy