From 84a1169f7dd6299462433f77273ca607e02dd1e9 Mon Sep 17 00:00:00 2001 From: fortyseven_degrees Date: Mon, 19 Dec 2022 05:18:30 +0000 Subject: [PATCH 1/5] 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 092d9e0885c855e7199a71d0307573c231d8d9f6 Mon Sep 17 00:00:00 2001 From: fortyseven_degrees Date: Mon, 19 Dec 2022 05:18:33 +0000 Subject: [PATCH 2/5] Update http4s-blaze-server to 0.23.13 --- project/ProjectPlugin.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/ProjectPlugin.scala b/project/ProjectPlugin.scala index c19b6ca3..f0f00440 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.33" + lazy val http4s = "0.23.13" lazy val circe = "0.14.2" lazy val log4s = "1.7.0" lazy val scalatest = "3.2.14" From b667a3c6294f2e854c24ff191d77c4a6a915a2a6 Mon Sep 17 00:00:00 2001 From: fortyseven_degrees Date: Mon, 16 Jan 2023 05:32:53 +0000 Subject: [PATCH 3/5] Revert commit(s) 092d9e0, 84a1169 --- project/ProjectPlugin.scala | 2 +- .../scala/org/scalaexercises/evaluator/auth.scala | 7 +++---- .../org/scalaexercises/evaluator/services.scala | 13 ++++++------- .../scalaexercises/evaluator/EvalEndpointSpec.scala | 5 ++--- 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/project/ProjectPlugin.scala b/project/ProjectPlugin.scala index f0f00440..c19b6ca3 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.23.13" + lazy val http4s = "0.21.33" lazy val circe = "0.14.2" lazy val log4s = "1.7.0" lazy val scalatest = "3.2.14" diff --git a/server/src/main/scala/org/scalaexercises/evaluator/auth.scala b/server/src/main/scala/org/scalaexercises/evaluator/auth.scala index 70f4864f..cf3a81ef 100644 --- a/server/src/main/scala/org/scalaexercises/evaluator/auth.scala +++ b/server/src/main/scala/org/scalaexercises/evaluator/auth.scala @@ -25,7 +25,6 @@ import org.log4s.getLogger import pdi.jwt.{Jwt, JwtAlgorithm} import scala.util.{Failure, Success} -import org.typelevel.ci.CIString object auth { @@ -51,18 +50,18 @@ object auth { type HeaderT = `X-Scala-Eval-Api-Token` - def name: CIString = CIString("x-scala-eval-api-token") + def name: CaseInsensitiveString = CaseInsensitiveString("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.Raw): Option[HeaderT] = + def matchHeader(header: Header): 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.Raw.Parsed { + final case class `X-Scala-Eval-Api-Token`(token: String) extends Header.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 4cf7218b..8a67c58b 100644 --- a/server/src/main/scala/org/scalaexercises/evaluator/services.scala +++ b/server/src/main/scala/org/scalaexercises/evaluator/services.scala @@ -25,24 +25,23 @@ import io.circe.syntax._ import org.http4s._ import org.http4s.dsl._ import org.http4s.headers.Allow -import org.http4s.blaze.server._ +import org.http4s.server.blaze._ 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.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()) + 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()) ) 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 ccc8aba2..f14f4dd6 100644 --- a/server/src/test/scala/org/scalaexercises/evaluator/EvalEndpointSpec.scala +++ b/server/src/test/scala/org/scalaexercises/evaluator/EvalEndpointSpec.scala @@ -26,7 +26,6 @@ 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 { @@ -44,10 +43,10 @@ class EvalEndpointSpec extends AnyFunSpec with Matchers with Implicits { val server = auth[IO](service[IO](evaluator)) - def serve(evalRequest: EvalRequest, authHeader: Header.Raw): Response[IO] = + def serve(evalRequest: EvalRequest, authHeader: Header): Response[IO] = server .run( - Request[IO](POST, Uri(path = path"/eval")) + Request[IO](POST, Uri(path = "/eval")) .withEntity(evalRequest) .putHeaders(authHeader) ) From efb87f9afa47758e63182074b3e443ae352ceeeb Mon Sep 17 00:00:00 2001 From: fortyseven_degrees Date: Mon, 16 Jan 2023 05:33:53 +0000 Subject: [PATCH 4/5] 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 47f36d83ab99fd9213cd3d659a7aa00801c440cc Mon Sep 17 00:00:00 2001 From: fortyseven_degrees Date: Mon, 16 Jan 2023 05:33:55 +0000 Subject: [PATCH 5/5] Update http4s-blaze-server to 0.23.13 --- project/ProjectPlugin.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/ProjectPlugin.scala b/project/ProjectPlugin.scala index 98603ce6..8ac595b8 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.13" lazy val circe = "0.14.2" lazy val log4s = "1.7.0" lazy val scalatest = "3.2.15"