diff --git a/bundle-monix-http4s-blaze/src/main/scala/com/avast/sst/bundle/MonixServerApp.scala b/bundle-monix-http4s-blaze/src/main/scala/com/avast/sst/bundle/MonixServerApp.scala index 5189db87c..bf13cb6d8 100644 --- a/bundle-monix-http4s-blaze/src/main/scala/com/avast/sst/bundle/MonixServerApp.scala +++ b/bundle-monix-http4s-blaze/src/main/scala/com/avast/sst/bundle/MonixServerApp.scala @@ -14,7 +14,7 @@ trait MonixServerApp extends TaskApp { private val logger = LoggerFactory.getLogger(this.getClass) - def program: Resource[Task, Server[Task]] + def program: Resource[Task, Server] override def run(args: List[String]): Task[ExitCode] = { program diff --git a/bundle-zio-http4s-blaze/src/main/scala/com/avast/sst/bundle/ZioServerApp.scala b/bundle-zio-http4s-blaze/src/main/scala/com/avast/sst/bundle/ZioServerApp.scala index 84ba4b976..e60d45fd7 100644 --- a/bundle-zio-http4s-blaze/src/main/scala/com/avast/sst/bundle/ZioServerApp.scala +++ b/bundle-zio-http4s-blaze/src/main/scala/com/avast/sst/bundle/ZioServerApp.scala @@ -17,7 +17,7 @@ trait ZioServerApp extends CatsApp { private val logger = LoggerFactory.getLogger(this.getClass) - def program: Resource[Task, Server[Task]] + def program: Resource[Task, Server] @nowarn("msg=dead code") override def run(args: List[String]): ZIO[ZEnv, Nothing, ExitCode] = { diff --git a/example/src/main/scala/com/avast/sst/example/Main.scala b/example/src/main/scala/com/avast/sst/example/Main.scala index b51c6ae26..99e9e7c41 100644 --- a/example/src/main/scala/com/avast/sst/example/Main.scala +++ b/example/src/main/scala/com/avast/sst/example/Main.scala @@ -30,7 +30,7 @@ import scala.concurrent.ExecutionContext object Main extends ZioServerApp { - def program: Resource[Task, Server[Task]] = { + def program: Resource[Task, Server] = { for { configuration <- Resource.eval(PureConfigModule.makeOrRaise[Task, Configuration]) executorModule <- ExecutorModule.makeFromExecutionContext[Task](runtime.platform.executor.asEC) diff --git a/http4s-client-blaze-pureconfig/src/main/scala/com/avast/sst/http4s/client/pureconfig/ConfigReaders.scala b/http4s-client-blaze-pureconfig/src/main/scala/com/avast/sst/http4s/client/pureconfig/ConfigReaders.scala index 5a6b68a3b..08f897487 100644 --- a/http4s-client-blaze-pureconfig/src/main/scala/com/avast/sst/http4s/client/pureconfig/ConfigReaders.scala +++ b/http4s-client-blaze-pureconfig/src/main/scala/com/avast/sst/http4s/client/pureconfig/ConfigReaders.scala @@ -2,7 +2,7 @@ package com.avast.sst.http4s.client.pureconfig import cats.syntax.either._ import com.avast.sst.http4s.client.Http4sBlazeClientConfig -import org.http4s.client.blaze.ParserMode +import org.http4s.blaze.client.ParserMode import org.http4s.headers.`User-Agent` import pureconfig.ConfigReader import pureconfig.error.CannotConvert diff --git a/http4s-client-blaze/src/main/scala/com/avast/sst/http4s/client/Http4sBlazeClientConfig.scala b/http4s-client-blaze/src/main/scala/com/avast/sst/http4s/client/Http4sBlazeClientConfig.scala index 9ab3b0885..c7b3702a9 100644 --- a/http4s-client-blaze/src/main/scala/com/avast/sst/http4s/client/Http4sBlazeClientConfig.scala +++ b/http4s-client-blaze/src/main/scala/com/avast/sst/http4s/client/Http4sBlazeClientConfig.scala @@ -1,9 +1,9 @@ package com.avast.sst.http4s.client -import org.http4s.BuildInfo -import org.http4s.client.blaze.ParserMode +import org.http4s.blaze.client.ParserMode import org.http4s.client.defaults -import org.http4s.headers.{AgentComment, AgentProduct, `User-Agent`} +import org.http4s.headers.`User-Agent` +import org.http4s.{BuildInfo, ProductComment, ProductId} import java.util.concurrent.TimeUnit import scala.concurrent.duration.{Duration, FiniteDuration} @@ -13,7 +13,7 @@ final case class Http4sBlazeClientConfig( idleTimeout: FiniteDuration = Duration(1, TimeUnit.MINUTES), requestTimeout: FiniteDuration = defaults.RequestTimeout, connectTimeout: FiniteDuration = defaults.ConnectTimeout, - userAgent: `User-Agent` = `User-Agent`(AgentProduct("http4s-blaze-client", Some(BuildInfo.version)), List(AgentComment("Server"))), + userAgent: `User-Agent` = `User-Agent`(ProductId("http4s-blaze-client", Some(BuildInfo.version)), List(ProductComment("Server"))), maxTotalConnections: Int = 10, maxWaitQueueLimit: Int = 256, maxConnectionsPerRequestkey: Int = 256, diff --git a/http4s-client-blaze/src/main/scala/com/avast/sst/http4s/client/Http4sBlazeClientModule.scala b/http4s-client-blaze/src/main/scala/com/avast/sst/http4s/client/Http4sBlazeClientModule.scala index 868967f80..9f4fb61c2 100644 --- a/http4s-client-blaze/src/main/scala/com/avast/sst/http4s/client/Http4sBlazeClientModule.scala +++ b/http4s-client-blaze/src/main/scala/com/avast/sst/http4s/client/Http4sBlazeClientModule.scala @@ -1,8 +1,8 @@ package com.avast.sst.http4s.client import cats.effect.{ConcurrentEffect, Resource} +import org.http4s.blaze.client.BlazeClientBuilder import org.http4s.client.Client -import org.http4s.client.blaze.BlazeClientBuilder import javax.net.ssl.SSLContext import scala.concurrent.ExecutionContext diff --git a/http4s-client-blaze/src/test/scala/com/avast/sst/http4s/client/Http4SBlazeClientTest.scala b/http4s-client-blaze/src/test/scala/com/avast/sst/http4s/client/Http4SBlazeClientTest.scala index a9006581e..593e55c01 100644 --- a/http4s-client-blaze/src/test/scala/com/avast/sst/http4s/client/Http4SBlazeClientTest.scala +++ b/http4s-client-blaze/src/test/scala/com/avast/sst/http4s/client/Http4SBlazeClientTest.scala @@ -2,6 +2,7 @@ package com.avast.sst.http4s.client import cats.effect._ import org.http4s.headers._ +import org.http4s.{ProductComment, ProductId} import org.scalatest.funsuite.AsyncFunSuite import scala.concurrent.ExecutionContext @@ -19,7 +20,7 @@ class Http4SBlazeClientTest extends AsyncFunSuite { val test = for { client <- Http4sBlazeClientModule.make[IO]( Http4sBlazeClientConfig( - userAgent = `User-Agent`(AgentProduct("http4s-client", Some("1.2.3")), List(AgentComment("Test"))) + userAgent = `User-Agent`(ProductId("http4s-client", Some("1.2.3")), List(ProductComment("Test"))) ), ExecutionContext.global ) diff --git a/http4s-server-blaze/src/main/scala/com/avast/sst/http4s/server/Http4sBlazeServerModule.scala b/http4s-server-blaze/src/main/scala/com/avast/sst/http4s/server/Http4sBlazeServerModule.scala index 90a2b2221..a09c85e2d 100644 --- a/http4s-server-blaze/src/main/scala/com/avast/sst/http4s/server/Http4sBlazeServerModule.scala +++ b/http4s-server-blaze/src/main/scala/com/avast/sst/http4s/server/Http4sBlazeServerModule.scala @@ -2,8 +2,8 @@ package com.avast.sst.http4s.server import cats.effect.{ConcurrentEffect, Resource, Timer} import org.http4s.HttpApp +import org.http4s.blaze.server.BlazeServerBuilder import org.http4s.server.Server -import org.http4s.server.blaze.BlazeServerBuilder import java.net.{InetSocketAddress, StandardSocketOptions} import scala.concurrent.ExecutionContext @@ -19,7 +19,7 @@ object Http4sBlazeServerModule { config: Http4sBlazeServerConfig, httpApp: HttpApp[F], executionContext: ExecutionContext - ): Resource[F, Server[F]] = { + ): Resource[F, Server] = { for { inetSocketAddress <- Resource.eval( ConcurrentEffect[F].delay( diff --git a/http4s-server/src/main/scala/com/avast/sst/http4s/server/middleware/CorrelationIdMiddleware.scala b/http4s-server/src/main/scala/com/avast/sst/http4s/server/middleware/CorrelationIdMiddleware.scala index 1d9001a5a..63372b51c 100644 --- a/http4s-server/src/main/scala/com/avast/sst/http4s/server/middleware/CorrelationIdMiddleware.scala +++ b/http4s-server/src/main/scala/com/avast/sst/http4s/server/middleware/CorrelationIdMiddleware.scala @@ -1,13 +1,13 @@ package com.avast.sst.http4s.server.middleware -import cats.data.{Kleisli, OptionT} +import cats.data.{Kleisli, NonEmptyList, OptionT} import cats.effect.Sync import cats.syntax.functor._ import com.avast.sst.http4s.server.middleware.CorrelationIdMiddleware.CorrelationId -import io.chrisdavenport.vault.Key -import org.http4s.util.CaseInsensitiveString import org.http4s.{Header, HttpRoutes, Request, Response} import org.slf4j.LoggerFactory +import org.typelevel.ci.CIString +import org.typelevel.vault.Key import java.util.UUID @@ -17,7 +17,7 @@ import java.util.UUID * Use method `retrieveCorrelationId` to get the value from request attributes. */ class CorrelationIdMiddleware[F[_]: Sync]( - correlationIdHeaderName: CaseInsensitiveString, + correlationIdHeaderName: CIString, attributeKey: Key[CorrelationId], generator: () => String ) { @@ -29,7 +29,7 @@ class CorrelationIdMiddleware[F[_]: Sync]( def wrap(routes: HttpRoutes[F]): HttpRoutes[F] = Kleisli[OptionT[F, *], Request[F], Response[F]] { request => request.headers.get(correlationIdHeaderName) match { - case Some(header) => + case Some(NonEmptyList(header, _)) => val requestWithAttribute = request.withAttribute(attributeKey, CorrelationId(header.value)) routes(requestWithAttribute).map(r => r.withHeaders(r.headers.put(header))) case None => @@ -38,7 +38,7 @@ class CorrelationIdMiddleware[F[_]: Sync]( _ <- log(newCorrelationId) requestWithAttribute = request.withAttribute(attributeKey, CorrelationId(newCorrelationId)) response <- routes(requestWithAttribute) - } yield response.withHeaders(response.headers.put(Header(correlationIdHeaderName.value, newCorrelationId))) + } yield response.withHeaders(response.headers.put(Header.Raw(correlationIdHeaderName, newCorrelationId))) } } @@ -62,7 +62,7 @@ object CorrelationIdMiddleware { @SuppressWarnings(Array("scalafix:Disable.toString")) def default[F[_]: Sync]: F[CorrelationIdMiddleware[F]] = { Key.newKey[F, CorrelationId].map { attributeKey => - new CorrelationIdMiddleware(CaseInsensitiveString("Correlation-ID"), attributeKey, () => UUID.randomUUID().toString) + new CorrelationIdMiddleware(CIString("Correlation-ID"), attributeKey, () => UUID.randomUUID().toString) } } diff --git a/http4s-server/src/test/scala/com/avast/sst/http4s/server/middleware/CorrelationIdMiddlewareTest.scala b/http4s-server/src/test/scala/com/avast/sst/http4s/server/middleware/CorrelationIdMiddlewareTest.scala index 4465aacab..27cf44fe7 100644 --- a/http4s-server/src/test/scala/com/avast/sst/http4s/server/middleware/CorrelationIdMiddlewareTest.scala +++ b/http4s-server/src/test/scala/com/avast/sst/http4s/server/middleware/CorrelationIdMiddlewareTest.scala @@ -2,12 +2,12 @@ package com.avast.sst.http4s.server.middleware import cats.effect.{ContextShift, IO, Resource, Timer} import com.avast.sst.http4s.server.Http4sRouting -import org.http4s.client.blaze.BlazeClientBuilder +import org.http4s.blaze.client.BlazeClientBuilder +import org.http4s.blaze.server.BlazeServerBuilder import org.http4s.dsl.Http4sDsl -import org.http4s.server.blaze.BlazeServerBuilder -import org.http4s.util.CaseInsensitiveString import org.http4s.{Header, HttpRoutes, Request, Uri} import org.scalatest.funsuite.AsyncFunSuite +import org.typelevel.ci.CIString import java.net.InetSocketAddress import scala.concurrent.ExecutionContext @@ -25,7 +25,7 @@ class CorrelationIdMiddlewareTest extends AsyncFunSuite with Http4sDsl[IO] { middleware.wrap { HttpRoutes.of[IO] { case req @ GET -> Root / "test" => val id = middleware.retrieveCorrelationId(req) - Ok("test").map(_.withHeaders(Header("Attribute-Value", id.toString))) + Ok("test").map(_.withHeaders(Header.Raw(CIString("Attribute-Value"), id.toString))) } } } @@ -41,12 +41,12 @@ class CorrelationIdMiddlewareTest extends AsyncFunSuite with Http4sDsl[IO] { client .run( Request[IO](uri = Uri.unsafeFromString(s"http://${server.address.getHostString}:${server.address.getPort}/test")) - .withHeaders(Header("Correlation-Id", "test-value")) + .withHeaders(Header.Raw(CIString("Correlation-Id"), "test-value")) ) .use { response => IO.delay { - assert(response.headers.get(CaseInsensitiveString("Correlation-Id")).get.value === "test-value") - assert(response.headers.get(CaseInsensitiveString("Attribute-Value")).get.value === "Some(CorrelationId(test-value))") + assert(response.headers.get(CIString("Correlation-Id")).get.head.value === "test-value") + assert(response.headers.get(CIString("Attribute-Value")).get.head.value === "Some(CorrelationId(test-value))") } } } diff --git a/project/Dependencies.scala b/project/Dependencies.scala index e9715ac5e..4be052d44 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -45,7 +45,7 @@ object Dependencies { val datastaxJavaDriverCore = "4.13.0" val doobie = "0.13.4" val grpc = "1.39.0" - val http4s = "0.21.25" + val http4s = "0.22.2" val micrometerCore = "1.7.2" val micrometerJmx = "1.7.2" val micrometerStatsD = "1.7.2"