Created
March 8, 2018 20:32
-
-
Save mkotsur/1426e3eb5ea541030bb2959274db09e9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package hello | |
import io.circe.generic.auto._ | |
import io.github.mkotsur.aws.handler.Lambda._ | |
import io.github.mkotsur.aws.handler.Lambda | |
import com.amazonaws.services.lambda.runtime.Context | |
import io.github.mkotsur.aws.proxy | |
import io.github.mkotsur.aws.proxy.ProxyResponse | |
import ScalaHandler._ | |
object ScalaHandler { | |
case class Req(key1: String, key2: String, key3: String) | |
case class Resp(message: String, request: Req) | |
} | |
class ScalaHandler extends Lambda[Req, Resp] { | |
override def handle(req: Req, context: Context): Either[Throwable, Resp] = | |
Right(Resp("And this is how you do it with mkotsur/aws-lambda-scala", req)) | |
} | |
class ApiGatewayScalaHandler extends Proxy[Req, Resp] { | |
override def handle(input: proxy.ProxyRequest[Req], c: Context): Either[Throwable, ProxyResponse[Resp]] = { | |
val headers = Map("x-custom-response-header" -> "my custom response header value") | |
val responseBodyOption = input.body.map(req => Resp("And this is how you do it with mkotsur/aws-lambda-scala", req)) | |
Right(ProxyResponse(200, Some(headers), responseBodyOption)) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package: | |
artifact: target/scala-2.12/hello.jar | |
functions: | |
helloScala: | |
handler: hello.ScalaHandler::handle |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment