Skip to content

kellydavid/scala-server-lambda

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

http4s-lambda

http4s-lambda allows you to run http4s HttpServices over API Gateway and AWS Lambda.

Getting Started

First, add the dependency:

libraryDependencies += "io.github.howardjohn" %% "http4s-lambda" % "0.1.0"

Next, we define a simple HttpService. Then, we simply need to define a new class for Lambda.

object Route { // Set up the route val service: HttpService[IO] = HttpService[IO] { case GET -> Root / "hello" / name => Ok(s"Hello, $name!") } // Define the entry point for Lambda class EntryPoint extends LambdaHandler(service) }

The set up for EntryPoint is somewhat strange, but due to Lambda instantiating and instance with reflection, this seems to be the simplest declaration.

Once deployed to Lambda, the handler should be specified as <package>.Route$EntryPoint::handler.

Finally, an API can be created in API Gateway. Lambda Proxy integration must be enabled.

A complete example can be found in here. Note the use of serverless, which automates deployment of the package and sets up API Gateway, along with many other features.

About

Run http4s or akka-http over API Gateway and AWS Lambda

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Scala 100.0%