From e8a43a9e806466aa84f5de86875e8e7bf2cc972d Mon Sep 17 00:00:00 2001 From: anba Date: Fri, 24 Oct 2025 15:38:43 -0500 Subject: [PATCH 1/2] created ApplicationLoadBalancerResponseEvent model --- ...ApplicationLoadBalancerResponseEvent.scala | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 lambda/shared/src/main/scala/feral/lambda/events/ApplicationLoadBalancerResponseEvent.scala diff --git a/lambda/shared/src/main/scala/feral/lambda/events/ApplicationLoadBalancerResponseEvent.scala b/lambda/shared/src/main/scala/feral/lambda/events/ApplicationLoadBalancerResponseEvent.scala new file mode 100644 index 00000000..ba43e5de --- /dev/null +++ b/lambda/shared/src/main/scala/feral/lambda/events/ApplicationLoadBalancerResponseEvent.scala @@ -0,0 +1,88 @@ +/* + * Copyright 2021 Typelevel + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package feral.lambda.events + +import io.circe.{Decoder, Encoder, KeyDecoder, KeyEncoder} +import org.typelevel.ci.CIString + +sealed abstract class ApplicationLoadBalancerResponseEvent { + def statusCode: Int + def statusDescription: Option[String] + def headers: Option[Map[CIString, String]] + def multiValueHeaders: Option[Map[CIString, List[String]]] + def body: Option[String] + def isBase64Encoded: Boolean +} + +object ApplicationLoadBalancerResponseEvent { + implicit val ciStringKeyEncoder: KeyEncoder[CIString] = + KeyEncoder.encodeKeyString.contramap(_.toString) + implicit val ciStringKeyDecoder: KeyDecoder[CIString] = + KeyDecoder.decodeKeyString.map(CIString(_)) + + private implicit val mapStringEncoder: Encoder[Map[CIString, String]] = + Encoder.encodeMap[CIString, String] + private implicit val mapListEncoder: Encoder[Map[CIString, List[String]]] = + Encoder.encodeMap[CIString, List[String]] + + def apply( + statusCode: Int, + statusDescription: Option[String], + headers: Option[Map[CIString, String]], + multiValueHeaders: Option[Map[CIString, List[String]]], + body: Option[String], + isBase64Encoded: Boolean + ): ApplicationLoadBalancerResponseEvent = + Impl(statusCode, statusDescription, headers, multiValueHeaders, body, isBase64Encoded) + + implicit val encoder: Encoder[ApplicationLoadBalancerResponseEvent] = + Encoder.forProduct6( + "statusCode", + "statusDescription", + "headers", + "multiValueHeaders", + "body", + "isBase64Encoded" + )(x => + ( + x.statusCode, + x.statusDescription, + x.headers, + x.multiValueHeaders, + x.body, + x.isBase64Encoded + )) + + implicit val decoder: Decoder[ApplicationLoadBalancerResponseEvent] = + Decoder.forProduct6( + "statusCode", + "statusDescription", + "headers", + "multiValueHeaders", + "body", + "isBase64Encoded" + )(ApplicationLoadBalancerResponseEvent.apply) + + private final case class Impl( + statusCode: Int, + statusDescription: Option[String], + headers: Option[Map[CIString, String]], + multiValueHeaders: Option[Map[CIString, List[String]]], + body: Option[String], + isBase64Encoded: Boolean + ) extends ApplicationLoadBalancerResponseEvent +} From 653bb45fac9a8f462528bb06d93f915bc1d65d6d Mon Sep 17 00:00:00 2001 From: anba Date: Fri, 24 Oct 2025 15:44:04 -0500 Subject: [PATCH 2/2] fixed format --- .../lambda/events/ApplicationLoadBalancerResponseEvent.scala | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lambda/shared/src/main/scala/feral/lambda/events/ApplicationLoadBalancerResponseEvent.scala b/lambda/shared/src/main/scala/feral/lambda/events/ApplicationLoadBalancerResponseEvent.scala index ba43e5de..dabec6d9 100644 --- a/lambda/shared/src/main/scala/feral/lambda/events/ApplicationLoadBalancerResponseEvent.scala +++ b/lambda/shared/src/main/scala/feral/lambda/events/ApplicationLoadBalancerResponseEvent.scala @@ -16,7 +16,10 @@ package feral.lambda.events -import io.circe.{Decoder, Encoder, KeyDecoder, KeyEncoder} +import io.circe.Decoder +import io.circe.Encoder +import io.circe.KeyDecoder +import io.circe.KeyEncoder import org.typelevel.ci.CIString sealed abstract class ApplicationLoadBalancerResponseEvent {