https://kotlinlang.org logo
#http4k
Title
# http4k
s

snowe

12/05/2023, 9:57 PM
I’m getting
Copy code
"java.lang.IllegalStateException: method is invalid\n\tat org.http4k.serverless.ApiGatewayV2AwsHttpAdapter.toHttp4kRequest(ApiGatewayV2.kt:48)\n\tat org.http4k.serverless.ApiGatewayV2AwsHttpAdapter.invoke(ApiGatewayV2.kt:64)\n\tat org.http4k.serverless.ApiGatewayV2AwsHttpAdapter.invoke(ApiGatewayV2.kt:45)\n\tat org.http4k.serverless.ApiGatewayFnLoader.invoke$lambda$0(ApiGatewayFnLoader.kt:24)\n\tat org.http4k.serverless.AwsLambdaRuntime$asServer$1$start$1$1.invoke(AwsLambdaRuntime.kt:44)\n\tat org.http4k.serverless.AwsLambdaRuntime$asServer$1$start$1$1.invoke(AwsLambdaRuntime.kt:40)\n\tat kotlin.concurrent.ThreadsKt$thread$thread$1.run(Thread.kt:30)\n"
when running my lambda in aws after following this tutorial: https://www.http4k.org/guide/tutorials/going_native_with_graal_on_aws_lambda/ The one thing I did differently is that I will not be setting up my lambda with routes through apigateway, it will just be direct lambda calls, so I had set up my handler like so:
Copy code
val handler = { request: Request -> Response(OK).body("Hello, ${request.query("name")}!") }

fun main() {
    ApiGatewayV2FnLoader(handler).asServer(AwsLambdaRuntime()).start()
}
does it have to be a
routes()
app rather than just a lambda function? I thought I had seen elsewhere in the docs that it could be any function to run.
2 Views