Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge http4s/http4s main #6

Merged
merged 16 commits into from
May 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 1 addition & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,8 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
scala: [2.12.15, 2.13.8]
scala: [2.13.8]
java: [temurin@8, temurin@11, temurin@17]
exclude:
- scala: 2.12.15
java: temurin@11
- scala: 2.12.15
java: temurin@17
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
Expand Down Expand Up @@ -216,16 +211,6 @@ jobs:
~/Library/Caches/Coursier/v1
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

- name: Download target directories (2.12.15)
uses: actions/download-artifact@v2
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.15

- name: Inflate target directories (2.12.15)
run: |
tar xf targets.tar
rm targets.tar

- name: Download target directories (2.13.8)
uses: actions/download-artifact@v2
with:
Expand Down
7 changes: 3 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
ThisBuild / tlBaseVersion := "0.23"
ThisBuild / tlMimaPreviousVersions ++= (0 to 11).map(y => s"0.23.$y").toSet
ThisBuild / tlBaseVersion := "1.0"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This branch establishes the 1.0 series.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect, thanks

ThisBuild / developers := List(
tlGitHubDev("rossabaker", "Ross A. Baker")
)

val Scala213 = "2.13.8"
ThisBuild / crossScalaVersions := Seq("2.12.15", Scala213)
ThisBuild / crossScalaVersions := Seq(Scala213)
ThisBuild / scalaVersion := Scala213

lazy val root = project.in(file(".")).aggregate(twirl).enablePlugins(NoPublishPlugin)

val http4sVersion = "0.23.12"
val http4sVersion = "1.0.0-M33"
val munitVersion = "0.7.29"
val munitCatsEffectVersion = "1.0.7"

Expand Down
19 changes: 8 additions & 11 deletions twirl/src/main/scala/org/http4s/twirl/TwirlInstances.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,27 @@ import org.http4s.MediaType
import org.http4s.headers.`Content-Type`

trait TwirlInstances {
implicit def htmlContentEncoder[F[_]](implicit
charset: Charset = `UTF-8`
): EntityEncoder[F, Html] =
implicit def htmlContentEncoder(implicit charset: Charset = `UTF-8`): EntityEncoder.Pure[Html] =
contentEncoder(MediaType.text.html)

/** Note: Twirl uses a media type of `text/javascript`. This is obsolete, so we instead return
* `application/javascript`.
*/
implicit def jsContentEncoder[F[_]](implicit
implicit def jsContentEncoder(implicit
charset: Charset = `UTF-8`
): EntityEncoder[F, JavaScript] =
): EntityEncoder.Pure[JavaScript] =
contentEncoder(MediaType.application.javascript)

implicit def xmlContentEncoder[F[_]](implicit charset: Charset = `UTF-8`): EntityEncoder[F, Xml] =
implicit def xmlContentEncoder(implicit charset: Charset = `UTF-8`): EntityEncoder.Pure[Xml] =
contentEncoder(MediaType.application.xml)

implicit def txtContentEncoder[F[_]](implicit charset: Charset = `UTF-8`): EntityEncoder[F, Txt] =
implicit def txtContentEncoder(implicit charset: Charset = `UTF-8`): EntityEncoder.Pure[Txt] =
contentEncoder(MediaType.text.plain)

private def contentEncoder[F[_], C <: Content](
private def contentEncoder[C <: Content](
mediaType: MediaType
)(implicit charset: Charset): EntityEncoder[F, C] =
EntityEncoder
.stringEncoder[F]
)(implicit charset: Charset): EntityEncoder.Pure[C] =
EntityEncoder.stringEncoder
.contramap[C](content => content.body)
.withContentType(`Content-Type`(mediaType, charset))
}