Skip to content

Instantly share code, notes, and snippets.

@mkotsur
Last active March 8, 2018 20:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mkotsur/5b54906a56e26d7080f3aa5088fd1ffe to your computer and use it in GitHub Desktop.
Save mkotsur/5b54906a56e26d7080f3aa5088fd1ffe to your computer and use it in GitHub Desktop.
package hello
import scala.beans.BeanProperty
case class ApiGatewayResponse(@BeanProperty statusCode: Integer, @BeanProperty body: String,
@BeanProperty headers: java.util.Map[String, Object], @BeanProperty base64Encoded: Boolean = false)
package hello
import com.amazonaws.services.lambda.runtime.{Context, RequestHandler}
import scala.collection.JavaConverters
class Handler extends RequestHandler[Request, Response] {
def handleRequest(input: Request, context: Context): Response = {
Response("Go Serverless v1.0! Your function executed successfully!", input)
}
}
class ApiGatewayHandler extends RequestHandler[Request, ApiGatewayResponse] {
def handleRequest(input: Request, context: Context): ApiGatewayResponse = {
val headers = Map("x-custom-response-header" -> "my custom response header value")
ApiGatewayResponse(200, "Go Serverless v1.0! Your function executed successfully!",
JavaConverters.mapAsJavaMap[String, Object](headers),
true)
}
}
package hello
import scala.beans.BeanProperty
class Request(@BeanProperty var key1: String, @BeanProperty var key2: String, @BeanProperty var key3: String) {
def this() = this("", "", "")
}
package hello
import scala.beans.BeanProperty
case class Response(@BeanProperty message: String, @BeanProperty request: Request)
package:
artifact: target/scala-2.12/hello.jar
functions:
hello:
handler: hello.Handler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment