Skip to content

Commit b4b69e3

Browse files
committedJul 12, 2022
Update scala version and main dependencies with removing @scala 2.12 support (it was dropped in http4s since 1.0.0-M31)
1 parent 1726ec6 commit b4b69e3

File tree

17 files changed

+59
-91
lines changed

17 files changed

+59
-91
lines changed
 

‎.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
strategy:
1313
matrix:
1414
java: [1.8, 1.11, 1.14]
15-
scala: [2.12.14, 2.13.6]
15+
scala: [2.13.8]
1616
steps:
1717
- uses: actions/checkout@v2
1818
- name: Set up JDK ${{ matrix.java }}

‎.github/workflows/mima.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
strategy:
1313
matrix:
1414
java: [1.14]
15-
scala: [2.12.14, 2.13.6]
15+
scala: [2.13.8]
1616
steps:
1717
- uses: actions/checkout@v2
1818
with:

‎.github/workflows/release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
strategy:
1616
matrix:
1717
java: [1.14]
18-
scala: [2.12.14, 2.13.6]
18+
scala: [2.13.8]
1919
steps:
2020
- uses: actions/checkout@v2
2121
with:

‎build.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ lazy val license = (ThisBuild / licenses) := Seq(
110110
lazy val buildSettings = publishing ++
111111
Seq(
112112
scalaVersion := scala_213,
113-
crossScalaVersions := Seq(scala_213, scala_212),
113+
crossScalaVersions := Seq(scala_213),
114114
scalacOptions --= disabledCompilerFlags,
115115
resolvers += Resolver.sonatypeRepo("snapshots"),
116116
(run / fork) := true,

‎core/src/main/scala-2.12-/jdk/CollectionConverters.scala

-5
This file was deleted.

‎core/src/main/scala-2.12-/scala/collection/compat/view/MapViewExtensionMethods.scala

-13
This file was deleted.

‎core/src/main/scala-2.12-/scala/collection/compat/view/package.scala

-7
This file was deleted.

‎core/src/main/scala/org/http4s/rho/bits/ResponseGenerator.scala

+22-25
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,14 @@ abstract class EntityResponseGenerator[F[_]](val status: Status) extends Respons
3939
apply(body, Headers.empty)
4040

4141
/** Generate a [[Result]] that carries the type information */
42-
def apply[A](body: A, headers: Headers)(implicit F: Monad[F], w: EntityEncoder[F, A]): F[T[A]] =
43-
w.toEntity(body) match {
44-
case Entity(proc, len) =>
45-
val hs = len match {
46-
case Some(l) => (w.headers ++ headers).put(`Content-Length`.unsafeFromLong(l))
47-
case None => w.headers ++ headers
48-
}
49-
F.pure(Result(Response[F](status = status, headers = hs, body = proc)).asInstanceOf[T[A]])
42+
def apply[A](body: A, headers: Headers)(implicit F: Monad[F], w: EntityEncoder[F, A]): F[T[A]] = {
43+
val entity = w.toEntity(body)
44+
val hs = entity.length match {
45+
case Some(l) => (w.headers ++ headers).put(`Content-Length`.unsafeFromLong(l))
46+
case None => w.headers ++ headers
5047
}
48+
F.pure(Result(Response[F](status = status, headers = hs, entity = entity)).asInstanceOf[T[A]])
49+
}
5150

5251
/** Generate wrapper free `Response` */
5352
def pure[A](body: A)(implicit F: Monad[F], w: EntityEncoder[F, A]): F[Response[F]] =
@@ -56,15 +55,14 @@ abstract class EntityResponseGenerator[F[_]](val status: Status) extends Respons
5655
/** Generate wrapper free `Response` */
5756
def pure[A](body: A, headers: Headers)(implicit
5857
F: Monad[F],
59-
w: EntityEncoder[F, A]): F[Response[F]] =
60-
w.toEntity(body) match {
61-
case Entity(proc, len) =>
62-
val hs = len match {
63-
case Some(l) => (w.headers ++ headers).put(`Content-Length`.unsafeFromLong(l))
64-
case None => w.headers ++ headers
65-
}
66-
F.pure(Response(status = status, headers = hs, body = proc))
58+
w: EntityEncoder[F, A]): F[Response[F]] = {
59+
val entity = w.toEntity(body)
60+
val hs = entity.length match {
61+
case Some(l) => (w.headers ++ headers).put(`Content-Length`.unsafeFromLong(l))
62+
case None => w.headers ++ headers
6763
}
64+
F.pure(Response(status = status, headers = hs, entity = entity))
65+
}
6866

6967
}
7068

@@ -76,15 +74,14 @@ abstract class LocationResponseGenerator[F[_]](val status: Status) extends Respo
7674

7775
def apply[A](location: Uri, body: A, headers: Headers = Headers.empty)(implicit
7876
F: Monad[F],
79-
w: EntityEncoder[F, A]): F[T[A]] =
80-
w.toEntity(body) match {
81-
case Entity(proc, len) =>
82-
val hs = (len match {
83-
case Some(l) => (w.headers ++ headers).put(`Content-Length`.unsafeFromLong(l))
84-
case None => w.headers ++ headers
85-
}).put(Location(location))
86-
F.pure(Result(Response[F](status = status, headers = hs, body = proc)).asInstanceOf[T[A]])
87-
}
77+
w: EntityEncoder[F, A]): F[T[A]] = {
78+
val entity = w.toEntity(body)
79+
val hs = (entity.length match {
80+
case Some(l) => (w.headers ++ headers).put(`Content-Length`.unsafeFromLong(l))
81+
case None => w.headers ++ headers
82+
}).put(Location(location))
83+
F.pure(Result(Response[F](status = status, headers = hs, entity = entity)).asInstanceOf[T[A]])
84+
}
8885
}
8986

9087
trait ResponseGeneratorInstances[F[_]] {

‎core/src/test/scala/ApiExamples.scala

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
import java.util.Date
2-
import java.util.UUID
3-
import java.time.Instant
4-
import java.util.concurrent.atomic.AtomicInteger
5-
61
import cats.effect.IO
72
import cats.syntax.all._
83
import munit.FunSuite
94
import org.http4s.headers.{ETag, `Content-Length`}
10-
import org.http4s.rho.bits.TypedQuery
115
import org.http4s.rho.RhoRoutes
12-
import org.http4s.server.websocket.WebSocketBuilder
6+
import org.http4s.rho.bits.TypedQuery
137
import org.http4s.{Request, UrlForm}
148

9+
import java.time.Instant
10+
import java.util.{Date, UUID}
11+
import java.util.concurrent.atomic.AtomicInteger
12+
1513
class ApiExamples extends FunSuite {
1614
test("A mock API should make it ease to compose routes") {
1715
/// src_inlined SimplePath
@@ -152,9 +150,10 @@ class ApiExamples extends FunSuite {
152150

153151
/* We can use a standard http4s.Response, but we don't get any metadata
154152
with it. Useful for things like Websocket support. */
155-
GET / "websockets" |>> { () =>
156-
WebSocketBuilder[IO].build(???, ???)
157-
}
153+
// TODO, how are websockets supported after the changes?
154+
// GET / "websockets" |>> { () =>
155+
// WebSocketBuilder[IO].build(???, ???)
156+
// }
158157
}
159158
/// end_src_inlined
160159

‎core/src/test/scala/org/http4s/rho/CodecRouterSuite.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class CodecRouterSuite extends CatsEffectSuite {
2121
test("A CodecRouter in a RhoRoutes should decode a valid body") {
2222
val b = Stream.emits(ArraySeq.unsafeWrapArray("hello".getBytes))
2323
val h = Headers(headers.`Content-Type`(MediaType.text.plain))
24-
val req = Request[IO](Method.POST, uri"/foo", headers = h, body = b)
24+
val req = Request[IO](Method.POST, uri"/foo", headers = h, entity = Entity(b))
2525

2626
for {
2727
result <- routes(req).value.map(_.getOrElse(Response.notFound))
@@ -33,7 +33,7 @@ class CodecRouterSuite extends CatsEffectSuite {
3333
val b = Stream.emits(ArraySeq.unsafeWrapArray("hello =".getBytes))
3434
val h = Headers(headers.`Content-Type`(MediaType.application.`x-www-form-urlencoded`))
3535
val req =
36-
Request[IO](Method.POST, uri"/form", headers = h, body = b)
36+
Request[IO](Method.POST, uri"/form", headers = h, entity = Entity(b))
3737

3838
assertIO(routes(req).value.map(_.map(_.status)), Some(Status.BadRequest))
3939
}

‎core/src/test/scala/org/http4s/rho/RhoRoutesSuite.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ class RhoRoutesSuite extends CatsEffectSuite with RequestRunner {
379379

380380
val body = Stream.emits(ArraySeq.unsafeWrapArray("foo".getBytes()))
381381
val uri = Uri.fromString("/foo/1?param=myparam").getOrElse(sys.error("Failed."))
382-
val req = Request[IO](method = Method.POST, uri = uri, body = body)
382+
val req = Request[IO](method = Method.POST, uri = uri, entity = Entity(body))
383383
.putHeaders(
384384
`Content-Type`(MediaType.text.plain),
385385
`Content-Length`.unsafeFromLong("foo".length)

‎core/src/test/scala/org/http4s/rho/bits/ResponseGeneratorSuite.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class ResponseGeneratorSuite extends CatsEffectSuite {
8181
test("A ResponseGenerator should explicitly added headers have priority") {
8282
implicit val w: EntityEncoder[IO, String] =
8383
EntityEncoder.encodeBy[IO, String](`Content-Type`(MediaType.text.html))(
84-
EntityEncoder.stringEncoder[IO].toEntity(_)
84+
EntityEncoder.stringEncoder.toEntity(_)
8585
)
8686

8787
assertIO(

‎core/src/test/scala/org/http4s/rho/bits/ResultMatcherSuite.scala

+4-4
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,10 @@ class ResultMatcherSuite extends FunSuite {
122122
case class ModelB(name: String, id: Long)
123123

124124
implicit def w1[F[_]]: EntityEncoder[F, ModelA] =
125-
EntityEncoder.simple[F, ModelA]()(_ => Chunk.array("A".getBytes))
125+
EntityEncoder.simple[ModelA]()(_ => Chunk.array("A".getBytes))
126126

127127
implicit def w2[F[_]]: EntityEncoder[F, ModelB] =
128-
EntityEncoder.simple[F, ModelB]()(_ => Chunk.array("B".getBytes))
128+
EntityEncoder.simple[ModelB]()(_ => Chunk.array("B".getBytes))
129129

130130
val srvc = new TRhoRoutes[IO] {
131131
GET / "foo" |>> { () =>
@@ -165,8 +165,8 @@ object Foo {
165165
case class FooB(name: String, id: Long)
166166

167167
implicit def w1[F[_]]: EntityEncoder[F, FooA] =
168-
EntityEncoder.simple[F, FooA]()(_ => Chunk.array("A".getBytes))
168+
EntityEncoder.simple[FooA]()(_ => Chunk.array("A".getBytes))
169169

170170
implicit def w2[F[_]]: EntityEncoder[F, FooB] =
171-
EntityEncoder.simple[F, FooB]()(_ => Chunk.array("B".getBytes))
171+
EntityEncoder.simple[FooB]()(_ => Chunk.array("B".getBytes))
172172
}

‎examples/src/main/scala/com/http4s/rho/swagger/demo/Main.scala

+2-4
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@ package com.http4s.rho.swagger.demo
22

33
import cats.effect.{ExitCode, IO, IOApp}
44
import com.http4s.rho.swagger.ui.SwaggerUi
5+
import org.http4s.blaze.server.BlazeServerBuilder
56
import org.http4s.implicits._
67
import org.http4s.rho.swagger.SwaggerMetadata
78
import org.http4s.rho.swagger.models.{Info, Tag}
89
import org.http4s.rho.swagger.syntax.{io => ioSwagger}
9-
import org.http4s.blaze.server.BlazeServerBuilder
1010
import org.log4s.getLogger
1111

12-
import scala.concurrent.ExecutionContext.global
13-
1412
object Main extends IOApp {
1513
private val logger = getLogger
1614

@@ -30,7 +28,7 @@ object Main extends IOApp {
3028
SwaggerUi[IO].createRhoMiddleware(swaggerMetadata = metadata)
3129
val myRoutes = new MyRoutes[IO](ioSwagger).toRoutes(swaggerUiRhoMiddleware)
3230

33-
BlazeServerBuilder[IO](global)
31+
BlazeServerBuilder[IO]
3432
.withHttpApp(myRoutes.orNotFound)
3533
.bindLocal(port)
3634
.serve

‎project/Dependencies.scala

+8-9
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ import Keys._
33

44
// format: off
55
object Dependencies {
6-
val http4sVersion = "0.23.1"
7-
val circeVersion = "0.14.1"
6+
val http4sVersion = "1.0.0-M34"
7+
val circeVersion = "0.14.2"
88

9-
val scala_213 = "2.13.6"
10-
val scala_212 = "2.12.14"
9+
val scala_213 = "2.13.8"
1110

1211

1312
lazy val circeCore = "io.circe" %% "circe-core" % circeVersion
@@ -18,20 +17,20 @@ object Dependencies {
1817
lazy val http4sBlaze = "org.http4s" %% "http4s-blaze-server" % http4sVersion
1918
lazy val http4sCirce = "org.http4s" %% "http4s-circe" % http4sVersion
2019
lazy val http4sXmlInstances = "org.http4s" %% "http4s-scala-xml" % http4sVersion
21-
lazy val swaggerModels = "io.swagger" % "swagger-models" % "1.6.3"
20+
lazy val swaggerModels = "io.swagger" % "swagger-models" % "1.6.6"
2221
lazy val swaggerCore = "io.swagger" % "swagger-core" % swaggerModels.revision
23-
lazy val logbackClassic = "ch.qos.logback" % "logback-classic" % "1.2.7"
22+
lazy val logbackClassic = "ch.qos.logback" % "logback-classic" % "1.2.6"
2423
lazy val uadetector = "net.sf.uadetector" % "uadetector-resources" % "2014.10"
2524
lazy val shapeless = "com.chuusai" %% "shapeless" % "2.3.7"
2625
lazy val scalaXml = "org.scala-lang.modules" %% "scala-xml" % "2.0.1"
2726
lazy val swaggerUi = "org.webjars" % "swagger-ui" % "3.52.5"
28-
lazy val munit = "org.scalameta" %% "munit" % "0.7.27" % "test"
29-
lazy val munitCatsEffect = "org.typelevel" %% "munit-cats-effect-3" % "1.0.6" % "test"
27+
lazy val munit = "org.scalameta" %% "munit" % "0.7.29" % "test"
28+
lazy val munitCatsEffect = "org.typelevel" %% "munit-cats-effect-3" % "1.0.7" % "test"
3029
lazy val scalacheckMunit = "org.scalameta" %% "munit-scalacheck" % munit.revision % "test"
3130

3231
lazy val `scala-reflect` = "org.scala-lang" % "scala-reflect"
3332

34-
val silencerVersion = "1.7.7"
33+
val silencerVersion = "1.7.9"
3534
lazy val silencerPlugin = compilerPlugin("com.github.ghik" % "silencer-plugin" % silencerVersion cross CrossVersion.full)
3635
lazy val silencerLib = "com.github.ghik" % "silencer-lib" % silencerVersion % Provided cross CrossVersion.full
3736
lazy val kindProjector = compilerPlugin("org.typelevel" % "kind-projector" % "0.13.2" cross CrossVersion.full)

‎swagger-ui/src/main/scala/com/http4s/rho/swagger/ui/SwaggerUiRoutes.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.http4s.rho.swagger.ui
22

3-
import cats.effect.{Sync}
3+
import cats.effect.Sync
44
import cats.implicits._
55
import org.http4s.headers.`Content-Type`
66
import org.http4s.rho.RhoRoutes
@@ -16,7 +16,7 @@ class SwaggerUiRoutes[F[_]: Sync](
1616

1717
private val htmlEncoder: EntityEncoder[F, String] =
1818
EntityEncoder
19-
.stringEncoder[F]
19+
.stringEncoder()
2020
.withContentType(`Content-Type`(MediaType.text.html).withCharset(org.http4s.Charset.`UTF-8`))
2121

2222
// Serving the html directly here would break all relative paths, so we redirect.

‎swagger/src/test/scala/org/http4s/rho/swagger/SwaggerModelsBuilderSuite.scala

+4-4
Original file line numberDiff line numberDiff line change
@@ -1064,21 +1064,21 @@ class SwaggerModelsBuilderSuite extends FunSuite {
10641064

10651065
implicit def renderableEncoder[F[_], T <: Renderable]: EntityEncoder[F, T] =
10661066
EntityEncoder
1067-
.stringEncoder[F](Charset.`UTF-8`)
1067+
.stringEncoder(Charset.`UTF-8`)
10681068
.contramap { _: T => "" }
10691069
.withContentType(`Content-Type`(MediaType.application.json, Charset.`UTF-8`))
10701070

10711071
implicit def tuple2Encoder[F[_], T <: Renderable]: EntityEncoder[F, (Int, T)] =
10721072
EntityEncoder
1073-
.stringEncoder[F](Charset.`UTF-8`)
1073+
.stringEncoder(Charset.`UTF-8`)
10741074
.contramap { _: (Int, T) => "" }
10751075
.withContentType(`Content-Type`(MediaType.application.json, Charset.`UTF-8`))
10761076

10771077
implicit def listEntityEncoder[F[_], A]: EntityEncoder[F, List[A]] =
1078-
EntityEncoder.simple[F, List[A]]()(_ => Chunk.array("A".getBytes))
1078+
EntityEncoder.simple[List[A]]()(_ => Chunk.array("A".getBytes))
10791079

10801080
implicit def mapEntityEncoder[F[_], A, B]: EntityEncoder[F, Map[A, B]] =
1081-
EntityEncoder.simple[F, Map[A, B]]()(_ => Chunk.array("A".getBytes))
1081+
EntityEncoder.simple[Map[A, B]]()(_ => Chunk.array("A".getBytes))
10821082

10831083
case class CsvFile()
10841084

0 commit comments

Comments
 (0)
Please sign in to comment.