From fa07b50753d8ca2b23a563f8ec971cfcb894c2c1 Mon Sep 17 00:00:00 2001 From: fortyseven_degrees Date: Fri, 27 Jan 2023 05:36:30 +0000 Subject: [PATCH 1/2] Applied Scalafix rule(s) github:http4s/http4s/v0_22?sha=series/0.22 --- .../scala/org/scalaexercises/evaluator/auth.scala | 7 ++++--- .../org/scalaexercises/evaluator/services.scala | 13 +++++++------ .../scalaexercises/evaluator/EvalEndpointSpec.scala | 5 +++-- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/server/src/main/scala/org/scalaexercises/evaluator/auth.scala b/server/src/main/scala/org/scalaexercises/evaluator/auth.scala index cf3a81ef..70f4864f 100644 --- a/server/src/main/scala/org/scalaexercises/evaluator/auth.scala +++ b/server/src/main/scala/org/scalaexercises/evaluator/auth.scala @@ -25,6 +25,7 @@ import org.log4s.getLogger import pdi.jwt.{Jwt, JwtAlgorithm} import scala.util.{Failure, Success} +import org.typelevel.ci.CIString object auth { @@ -50,18 +51,18 @@ object auth { type HeaderT = `X-Scala-Eval-Api-Token` - def name: CaseInsensitiveString = CaseInsensitiveString("x-scala-eval-api-token") + def name: CIString = CIString("x-scala-eval-api-token") override def parse(s: String): ParseResult[`X-Scala-Eval-Api-Token`] = ParseResult.success(`X-Scala-Eval-Api-Token`(s)) - def matchHeader(header: Header): Option[HeaderT] = + def matchHeader(header: Header.Raw): Option[HeaderT] = if (header.name == name) Some(`X-Scala-Eval-Api-Token`(header.value)) else None } - final case class `X-Scala-Eval-Api-Token`(token: String) extends Header.Parsed { + final case class `X-Scala-Eval-Api-Token`(token: String) extends Header.Raw.Parsed { override def key = `X-Scala-Eval-Api-Token` override def renderValue(writer: Writer): writer.type = writer.append(token) diff --git a/server/src/main/scala/org/scalaexercises/evaluator/services.scala b/server/src/main/scala/org/scalaexercises/evaluator/services.scala index 8a67c58b..4cf7218b 100644 --- a/server/src/main/scala/org/scalaexercises/evaluator/services.scala +++ b/server/src/main/scala/org/scalaexercises/evaluator/services.scala @@ -25,23 +25,24 @@ import io.circe.syntax._ import org.http4s._ import org.http4s.dsl._ import org.http4s.headers.Allow -import org.http4s.server.blaze._ +import org.http4s.blaze.server._ import org.http4s.syntax.kleisli.http4sKleisliResponseSyntaxOptionT import org.log4s.getLogger import org.scalaexercises.evaluator.codecs._ import scala.concurrent.duration._ +import org.typelevel.ci._ object services { import EvalResponse.messages._ val corsHeaders = Seq( - Header("Vary", "Origin,Access-Control-Request-Methods"), - Header("Access-Control-Allow-Methods", "POST"), - Header("Access-Control-Allow-Origin", "*"), - Header("Access-Control-Allow-Headers", "x-scala-eval-api-token, Content-Type"), - Header("Access-Control-Max-Age", 1.day.toSeconds.toString()) + Header.Raw(ci"Vary", "Origin,Access-Control-Request-Methods"), + Header.Raw(ci"Access-Control-Allow-Methods", "POST"), + Header.Raw(ci"Access-Control-Allow-Origin", "*"), + Header.Raw(ci"Access-Control-Allow-Headers", "x-scala-eval-api-token, Content-Type"), + Header.Raw(ci"Access-Control-Max-Age", 1.day.toSeconds.toString()) ) def service[F[_]: ConcurrentEffect: ContextShift: Timer: Sync](evaluator: Evaluator[F]) = { diff --git a/server/src/test/scala/org/scalaexercises/evaluator/EvalEndpointSpec.scala b/server/src/test/scala/org/scalaexercises/evaluator/EvalEndpointSpec.scala index f14f4dd6..ccc8aba2 100644 --- a/server/src/test/scala/org/scalaexercises/evaluator/EvalEndpointSpec.scala +++ b/server/src/test/scala/org/scalaexercises/evaluator/EvalEndpointSpec.scala @@ -26,6 +26,7 @@ import org.scalatest.Assertion import org.scalatest.funspec.AnyFunSpec import org.scalatest.matchers.should.Matchers import pdi.jwt.{Jwt, JwtAlgorithm} +import org.http4s.syntax.literals._ class EvalEndpointSpec extends AnyFunSpec with Matchers with Implicits { @@ -43,10 +44,10 @@ class EvalEndpointSpec extends AnyFunSpec with Matchers with Implicits { val server = auth[IO](service[IO](evaluator)) - def serve(evalRequest: EvalRequest, authHeader: Header): Response[IO] = + def serve(evalRequest: EvalRequest, authHeader: Header.Raw): Response[IO] = server .run( - Request[IO](POST, Uri(path = "/eval")) + Request[IO](POST, Uri(path = path"/eval")) .withEntity(evalRequest) .putHeaders(authHeader) ) From 1574ed14034913d4138c43ab386f98304e92519a Mon Sep 17 00:00:00 2001 From: fortyseven_degrees Date: Fri, 27 Jan 2023 05:36:34 +0000 Subject: [PATCH 2/2] Update http4s-circe, http4s-dsl to 0.23.18 --- project/ProjectPlugin.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/ProjectPlugin.scala b/project/ProjectPlugin.scala index 98603ce6..b4067919 100644 --- a/project/ProjectPlugin.scala +++ b/project/ProjectPlugin.scala @@ -17,7 +17,7 @@ object ProjectPlugin extends AutoPlugin { object V { lazy val cats = "2.9.0" lazy val catsEffect = "2.5.5" - lazy val http4s = "0.21.34" + lazy val http4s = "0.23.18" lazy val circe = "0.14.2" lazy val log4s = "1.7.0" lazy val scalatest = "3.2.15"