Skip to content

Commit 7371094

Browse files
committed
Use HttpRoutes over deprecated HttpService
1 parent e82d285 commit 7371094

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

http4s-lambda/src/main/scala/io/github/howardjohn/lambda/http4s/Http4sLambdaHandler.scala

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import org.http4s._
88

99
import scala.util.Try
1010

11-
class Http4sLambdaHandler(service: HttpService[IO]) extends LambdaHandler {
11+
class Http4sLambdaHandler(service: HttpRoutes[IO]) extends LambdaHandler {
1212
import Http4sLambdaHandler._
1313

1414
override def handleRequest(request: ProxyRequest): ProxyResponse =

http4s-lambda/src/test/scala/io/github/howardjohn/lambda/http4s/Http4sLambdaHandlerSpec.scala

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ import io.github.howardjohn.lambda.LambdaHandlerBehavior
77
import io.github.howardjohn.lambda.LambdaHandlerBehavior._
88
import org.http4s.circe._
99
import org.http4s.dsl.io._
10-
import org.http4s.{Header, HttpService}
10+
import org.http4s.{EntityDecoder, Header, HttpRoutes}
1111
import org.scalatest.{FeatureSpec, GivenWhenThen}
1212

1313
class Http4sLambdaHandlerSpec extends FeatureSpec with LambdaHandlerBehavior with GivenWhenThen {
14-
implicit val jsonDecoder = jsonOf[IO, JsonBody]
14+
implicit val jsonDecoder: EntityDecoder[IO, JsonBody] = jsonOf[IO, JsonBody]
15+
1516
object TimesQueryMatcher extends OptionalQueryParamDecoderMatcher[Int]("times")
16-
val route = HttpService[IO] {
17+
18+
val route: HttpRoutes[IO] = HttpRoutes.of[IO] {
1719
case GET -> Root / "hello" :? TimesQueryMatcher(times) =>
1820
Ok {
1921
Seq
@@ -29,6 +31,8 @@ class Http4sLambdaHandlerSpec extends FeatureSpec with LambdaHandlerBehavior wit
2931
case req @ POST -> Root / "post" => req.as[String].flatMap(s => Ok(s))
3032
case req @ POST -> Root / "json" => req.as[JsonBody].flatMap(s => Ok(LambdaHandlerBehavior.jsonReturn.asJson))
3133
}
34+
3235
val handler = new Http4sLambdaHandler(route)
36+
3337
scenariosFor(behavior(handler))
3438
}

0 commit comments

Comments
 (0)