Skip to content

Commit

Permalink
Merge pull request #549 from http4s/http4s-0.23
Browse files Browse the repository at this point in the history
Http4s 0.23 (Cats 3)
  • Loading branch information
zarthross authored Jun 27, 2021
2 parents 7c266ca + bbbbd46 commit e78ebdd
Show file tree
Hide file tree
Showing 61 changed files with 667 additions and 2,144 deletions.
56 changes: 23 additions & 33 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ lazy val rho = project
.in(file("."))
.disablePlugins(MimaPlugin)
.settings(buildSettings: _*)
.aggregate(`rho-core`, `rho-hal`, `rho-swagger`, `rho-swagger-ui`, `rho-examples`)
.aggregate(`rho-core`, `rho-swagger`, `rho-swagger-ui`, `rho-examples`)

lazy val `rho-core` = project
.in(file("core"))
Expand All @@ -32,12 +32,6 @@ lazy val `rho-core` = project
libraryDependencies ++= Seq("org.scala-lang.modules" %% "scala-collection-compat" % "2.4.4")
)

lazy val `rho-hal` = project
.in(file("hal"))
.settings(buildSettings :+ halDeps: _*)
.settings(mimaConfiguration)
.dependsOn(`rho-core`)

lazy val `rho-swagger` = project
.in(file("swagger"))
.settings(buildSettings :+ swaggerDeps: _*)
Expand Down Expand Up @@ -71,10 +65,8 @@ lazy val docs = project
version.value,
apiVersion.value
),
(ScalaUnidoc / unidoc / scalacOptions) ++= versionSpecificEnabledFlags(scalaVersion.value),
(ScalaUnidoc / unidoc / unidocProjectFilter) := inProjects(
`rho-core`,
`rho-hal`,
`rho-swagger`
),
git.remoteRepo := "[email protected]:http4s/rho.git",
Expand All @@ -87,7 +79,7 @@ lazy val docs = project
} yield (f, s"api/$major.$minor/$d")
}
)
.dependsOn(`rho-core`, `rho-hal`, `rho-swagger`)
.dependsOn(`rho-core`, `rho-swagger`)

lazy val `rho-examples` = project
.in(file("examples"))
Expand All @@ -96,27 +88,20 @@ lazy val `rho-examples` = project
.settings(Revolver.settings)
.settings(
exampleDeps,
libraryDependencies ++= Seq(logbackClassic, http4sXmlInstances),
dontPublish
)
.dependsOn(`rho-swagger`, `rho-swagger-ui`, `rho-hal`)

lazy val compilerFlags = Seq(
"-feature",
"-deprecation",
"-unchecked",
"-language:higherKinds",
"-language:existentials",
"-language:implicitConversions",
"-Ywarn-unused",
"-Xfatal-warnings"
.dependsOn(`rho-swagger`, `rho-swagger-ui`)

lazy val disabledCompilerFlags = Seq( // TODO: Fix code and re-enable these.
"-Xlint:package-object-classes",
"-Ywarn-numeric-widen",
"-Wnumeric-widen",
"-Xlint:adapted-args",
"-Yno-adapted-args",
"-Wdead-code",
"-Ywarn-dead-code"
)

def versionSpecificEnabledFlags(version: String) = CrossVersion.partialVersion(version) match {
case Some((2, 13)) => Seq.empty[String]
case _ => Seq("-Ypartial-unification")
}

/* Don't publish setting */
lazy val dontPublish = packagedArtifacts := Map.empty

Expand All @@ -128,22 +113,27 @@ lazy val buildSettings = publishing ++
Seq(
scalaVersion := scala_213,
crossScalaVersions := Seq(scala_213, scala_212),
scalacOptions := compilerFlags ++ versionSpecificEnabledFlags(scalaVersion.value),
scalacOptions --= disabledCompilerFlags,
resolvers += Resolver.sonatypeRepo("snapshots"),
(run / fork) := true,
(ThisBuild / organization) := "org.http4s",
(ThisBuild / homepage) := Some(url(homepageUrl)),
description := "A self documenting DSL build upon the http4s framework",
license,
libraryDependencies ++= Seq(
shapeless,
silencerPlugin,
silencerLib,
http4sServer % "provided",
logbackClassic % "test"
),
libraryDependencies ++= specs2,
libraryDependencies += `scala-reflect` % scalaVersion.value
libraryDependencies ++= (if (scalaVersion.value.startsWith("2"))
Seq(
shapeless,
silencerPlugin,
silencerLib,
kindProjector,
`scala-reflect` % scalaVersion.value
)
else Seq.empty),
libraryDependencies ++= specs2
)

// to keep REPL usable
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/org/http4s/rho/AuthedContext.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import cats.Monad
import cats.data.{Kleisli, OptionT}
import shapeless.{::, HNil}
import org.http4s.rho.bits.{FailureResponseOps, SuccessResponse, TypedHeader}
import _root_.io.chrisdavenport.vault._
import cats.effect._
import org.typelevel.vault.Key

/** The [[AuthedContext]] provides a convenient way to define a RhoRoutes
* which works with http4s authentication middleware.
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/org/http4s/rho/CompileRoutes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ object CompileRoutes {
* @param routes `Seq` of routes to bundle into a service.
* @return An `HttpRoutes`
*/
def foldRoutes[F[_]: Defer: Monad](routes: Seq[RhoRoute.Tpe[F]]): HttpRoutes[F] = {
def foldRoutes[F[_]: Monad](routes: Seq[RhoRoute.Tpe[F]]): HttpRoutes[F] = {
val tree = routes.foldLeft(PathTree[F]())((t, r) => t.appendRoute(r))
HttpRoutes((req: Request[F]) => tree.getResult(req).toResponse)
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/org/http4s/rho/PathBuilder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class PathBuilder[F[_], T <: HList](val method: Method, val path: PathRule
with HeaderAppendable[F, T]
with RoutePrependable[F, PathBuilder[F, T]]
with UriConvertible[F] {
type HeaderAppendResult[T <: HList] = Router[F, T]
type HeaderAppendResult[T0 <: HList] = Router[F, T0]

override val rules: RequestRule[F] = EmptyRule[F]()

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/org/http4s/rho/QueryBuilder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ case class QueryBuilder[F[_], T <: HList](method: Method, path: PathRule, rules:
override def /:(prefix: TypedPath[F, HNil]): QueryBuilder[F, T] =
new QueryBuilder[F, T](method, PathAnd(prefix.rule, path), rules)

override type HeaderAppendResult[T <: HList] = Router[F, T]
override type HeaderAppendResult[T0 <: HList] = Router[F, T0]

override def makeRoute(action: Action[F, T]): RhoRoute[F, T] =
RhoRoute(Router(method, path, rules), action)
Expand Down
20 changes: 7 additions & 13 deletions core/src/main/scala/org/http4s/rho/Result.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ package rho

import cats._
import org.http4s.headers.`Content-Type`
import _root_.io.chrisdavenport.vault._
import org.typelevel.vault._
import org.typelevel.ci.CIString

/** A helper for capturing the result types and status codes from routes */
sealed case class Result[
Expand Down Expand Up @@ -102,23 +103,19 @@ trait ResultSyntaxInstances[F[_]] {

def withHeaders(headers: Headers): Self = Result(resp.withHeaders(headers))

def withHeaders(headers: Header*): Self = Result(resp.withHeaders(headers: _*))
def withHeaders(headers: Header.ToRaw*): Self = Result(resp.withHeaders(headers: _*))

def withAttributes(attributes: Vault): Self = Result(resp.withAttributes(attributes))

def transformHeaders(f: Headers => Headers): Self = Result(resp.transformHeaders(f))

def filterHeaders(f: Header => Boolean): Self = Result(resp.filterHeaders(f))
def filterHeaders(f: Header.Raw => Boolean): Self = Result(resp.filterHeaders(f))

def removeHeader(key: HeaderKey): Self = Result(resp.removeHeader(key))
def removeHeader(key: CIString): Self = Result(resp.removeHeader(key))

def putHeaders(headers: Header*): Self = Result(resp.putHeaders(headers: _*))
def removeHeader[A](implicit h: Header[A, _]): Self = Result(resp.removeHeader(h))

@scala.deprecated("Use withHeaders instead", "0.20.0-M2")
def replaceAllHeaders(headers: Headers): Self = Result(resp.replaceAllHeaders(headers))

@scala.deprecated("Use withHeaders instead", "0.20.0-M2")
def replaceAllHeaders(headers: Header*): Self = Result(resp.replaceAllHeaders(headers: _*))
def putHeaders(headers: Header.ToRaw*): Self = Result(resp.putHeaders(headers: _*))

def withTrailerHeaders(trailerHeaders: F[Headers]): Self = Result(
resp.withTrailerHeaders(trailerHeaders)
Expand All @@ -128,9 +125,6 @@ trait ResultSyntaxInstances[F[_]] {

def trailerHeaders(implicit F: Applicative[F]): F[Headers] = resp.trailerHeaders(F)

@scala.deprecated("Use withContentType(`Content-Type`(t)) instead", "0.20.0-M2")
def withType(t: MediaType)(implicit F: Functor[F]): Self = Result(resp.withType(t)(F))

def withContentType(contentType: `Content-Type`): Self = Result(
resp.withContentType(contentType)
)
Expand Down
Loading

0 comments on commit e78ebdd

Please sign in to comment.