Browse Source

Update http4s and dependencies (#6753)

Rafał Sumisławski 4 years ago
parent
commit
ce283e71bb

+ 9 - 9
frameworks/Scala/http4s/build.sbt

@@ -2,7 +2,7 @@ name := "http4s"
 
 
 version := "1.0"
 version := "1.0"
 
 
-scalaVersion := "2.13.5"
+scalaVersion := "2.13.6"
 
 
 scalacOptions ++= Seq(
 scalacOptions ++= Seq(
   "-deprecation",
   "-deprecation",
@@ -18,7 +18,7 @@ scalacOptions ++= Seq(
 
 
 enablePlugins(SbtTwirl)
 enablePlugins(SbtTwirl)
 
 
-val http4sVersion = "0.21.22"
+val http4sVersion = "0.23.1"
 
 
 assembly / assemblyMergeStrategy := {
 assembly / assemblyMergeStrategy := {
   case PathList(xs @ _*) if xs.last == "io.netty.versions.properties" => MergeStrategy.rename
   case PathList(xs @ _*) if xs.last == "io.netty.versions.properties" => MergeStrategy.rename
@@ -31,13 +31,13 @@ libraryDependencies ++= Seq(
   "org.http4s" %% "http4s-twirl" % http4sVersion,
   "org.http4s" %% "http4s-twirl" % http4sVersion,
   "org.http4s" %% "http4s-circe" % http4sVersion,
   "org.http4s" %% "http4s-circe" % http4sVersion,
   // Optional for auto-derivation of JSON codecs
   // Optional for auto-derivation of JSON codecs
-  "io.circe" %% "circe-generic" % "0.13.0",
-  "org.typelevel" %% "cats-effect" % "2.5.0",
-  "co.fs2" %% "fs2-core" % "2.5.5",
-  "co.fs2" %% "fs2-io" % "2.5.5",
-  "io.getquill" %% "quill-jasync-postgres" % "3.7.0",
-  "io.getquill" %% "quill-jasync" % "3.7.0",
-  "ch.qos.logback" % "logback-classic" % "1.2.3"
+  "io.circe" %% "circe-generic" % "0.14.1",
+  "org.typelevel" %% "cats-effect" % "3.2.2",
+  "co.fs2" %% "fs2-core" % "3.1.0",
+  "co.fs2" %% "fs2-io" % "3.1.0",
+  "io.getquill" %% "quill-jasync-postgres" % "3.9.0",
+  "io.getquill" %% "quill-jasync" % "3.9.0",
+  "ch.qos.logback" % "logback-classic" % "1.2.5"
 )
 )
 
 
 addCompilerPlugin("com.olegpy" %% "better-monadic-for" % "0.3.1")
 addCompilerPlugin("com.olegpy" %% "better-monadic-for" % "0.3.1")

+ 2 - 4
frameworks/Scala/http4s/src/main/scala/http4s/techempower/benchmark/DatabaseService.scala

@@ -3,13 +3,11 @@ package http4s.techempower.benchmark
 import java.util.concurrent.{Executor, ThreadLocalRandom}
 import java.util.concurrent.{Executor, ThreadLocalRandom}
 
 
 import scala.concurrent.{ExecutionContext, ExecutionContextExecutor}
 import scala.concurrent.{ExecutionContext, ExecutionContextExecutor}
-import cats.effect.{ContextShift, IO => CatsIO}
+import cats.effect.{IO => CatsIO}
 import cats.syntax.all._
 import cats.syntax.all._
 import io.getquill._
 import io.getquill._
 
 
-class DatabaseService(ctx: PostgresJAsyncContext[LowerCase.type], executor: Executor)(implicit
-    cs: ContextShift[CatsIO]
-) {
+class DatabaseService(ctx: PostgresJAsyncContext[LowerCase.type], executor: Executor) {
   implicit val dbExecutionContext: ExecutionContextExecutor = ExecutionContext.fromExecutor(executor)
   implicit val dbExecutionContext: ExecutionContextExecutor = ExecutionContext.fromExecutor(executor)
   import ctx._
   import ctx._
 
 

+ 5 - 3
frameworks/Scala/http4s/src/main/scala/http4s/techempower/benchmark/WebServer.scala

@@ -1,7 +1,6 @@
 package http4s.techempower.benchmark
 package http4s.techempower.benchmark
 
 
 import java.util.concurrent.Executors
 import java.util.concurrent.Executors
-
 import scala.concurrent.ExecutionContext
 import scala.concurrent.ExecutionContext
 import cats.effect.{ExitCode, IO, IOApp, Resource}
 import cats.effect.{ExitCode, IO, IOApp, Resource}
 import com.typesafe.config.ConfigValueFactory
 import com.typesafe.config.ConfigValueFactory
@@ -15,7 +14,8 @@ import org.http4s.dsl._
 import org.http4s.circe._
 import org.http4s.circe._
 import org.http4s.implicits._
 import org.http4s.implicits._
 import org.http4s.server.Router
 import org.http4s.server.Router
-import org.http4s.server.blaze.BlazeServerBuilder
+import org.http4s.blaze.server.BlazeServerBuilder
+import org.http4s.headers.Server
 import org.http4s.twirl._
 import org.http4s.twirl._
 
 
 final case class Message(message: String)
 final case class Message(message: String)
@@ -63,9 +63,11 @@ object WebServer extends IOApp with Http4sDsl[IO] {
   // Add Server header container server address
   // Add Server header container server address
   def addServerHeader(service: HttpRoutes[IO]): HttpRoutes[IO] =
   def addServerHeader(service: HttpRoutes[IO]): HttpRoutes[IO] =
     cats.data.Kleisli { req: Request[IO] =>
     cats.data.Kleisli { req: Request[IO] =>
-      service.run(req).map(_.putHeaders(Header("Server", req.serverAddr)))
+      service.run(req).map(_.putHeaders(server))
     }
     }
 
 
+  val server = Server(ProductId("http4s", None))
+
   // HTTP service definition
   // HTTP service definition
   def service(db: DatabaseService) =
   def service(db: DatabaseService) =
     addServerHeader(HttpRoutes.of[IO] {
     addServerHeader(HttpRoutes.of[IO] {