Skip to content

Commit

Permalink
Merge branch 'main' into customauthprovidingzio
Browse files Browse the repository at this point in the history
  • Loading branch information
jdegoes authored Dec 21, 2023
2 parents 2aa1930 + f4b68d2 commit 0b161cb
Show file tree
Hide file tree
Showing 106 changed files with 10,348 additions and 1,448 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @amitksingh1490 @jdegoes @vigoo @adamgfraser
* @amitksingh1490 @jdegoes @vigoo @adamgfraser @987Nabil
32 changes: 16 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.12.18, 2.13.10, 3.3.0]
scala: [2.12.18, 2.13.12, 3.3.1]
java: [graal_graalvm@17, temurin@8]
runs-on: ${{ matrix.os }}
timeout-minutes: 60
Expand Down Expand Up @@ -54,8 +54,8 @@ jobs:
cache: sbt

- name: Check formatting
if: matrix.scala == '2.13.10'
run: sbt ++2.13.10 fmtCheck
if: matrix.scala == '2.13.12'
run: sbt ++2.13.12 fmtCheck

- name: Check that workflows are up to date
run: sbt '++ ${{ matrix.scala }}' githubWorkflowCheck
Expand All @@ -65,16 +65,16 @@ jobs:

- name: Check doc generation
if: ${{ github.event_name == 'pull_request' }}
run: sbt ++2.13.10 doc
run: sbt ++2.13.12 doc

- name: zio-http-shaded Tests
if: matrix.scala == '2.13.10'
if: matrix.scala == '2.13.12'
env:
PUBLISH_SHADED: true
run: sbt '++ ${{ matrix.scala }}' zioHttpShadedTests/test

- name: Compress target directories
run: tar cf targets.tar zio-http-cli/target target zio-http/target zio-http-docs/target zio-http-benchmarks/target zio-http-example/target zio-http-testkit/target project/target
run: tar cf targets.tar zio-http-cli/target target zio-http/target zio-http-docs/target zio-http-gen/target zio-http-benchmarks/target zio-http-example/target zio-http-testkit/target project/target

- name: Upload target directories
uses: actions/upload-artifact@v3
Expand All @@ -89,7 +89,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.13.10]
scala: [2.13.12]
java: [graal_graalvm@17]
runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -126,22 +126,22 @@ jobs:
tar xf targets.tar
rm targets.tar
- name: Download target directories (2.13.10)
- name: Download target directories (2.13.12)
uses: actions/download-artifact@v3
with:
name: target-${{ matrix.os }}-2.13.10-${{ matrix.java }}
name: target-${{ matrix.os }}-2.13.12-${{ matrix.java }}

- name: Inflate target directories (2.13.10)
- name: Inflate target directories (2.13.12)
run: |
tar xf targets.tar
rm targets.tar
- name: Download target directories (3.3.0)
- name: Download target directories (3.3.1)
uses: actions/download-artifact@v3
with:
name: target-${{ matrix.os }}-3.3.0-${{ matrix.java }}
name: target-${{ matrix.os }}-3.3.1-${{ matrix.java }}

- name: Inflate target directories (3.3.0)
- name: Inflate target directories (3.3.1)
run: |
tar xf targets.tar
rm targets.tar
Expand Down Expand Up @@ -182,7 +182,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.13.10]
scala: [2.13.12]
java: [temurin@8]
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -193,7 +193,7 @@ jobs:

- name: Add Scoverage
id: add_plugin
run: sed -i -e '$aaddSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.9.3")' project/plugins.sbt
run: sed -i -e '$aaddSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.9")' project/plugins.sbt

- name: Update Build Definition
id: update_build_definition
Expand All @@ -215,7 +215,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.13.10]
scala: [2.13.12]
java: [temurin@8]
runs-on: ${{ matrix.os }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = 3.7.14
version = 3.7.17
maxColumn = 120

align.preset = more
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ZIO HTTP is a scala library for building http apps. It is powered by ZIO and [Ne
Setup via `build.sbt`:

```scala
libraryDependencies += "dev.zio" %% "zio-http" % "3.0.0-RC3"
libraryDependencies += "dev.zio" %% "zio-http" % "3.0.0-RC4"
```

**NOTES ON VERSIONING:**
Expand Down
49 changes: 38 additions & 11 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import BuildHelper._
import Dependencies._
import Dependencies.{scalafmt, _}
import sbt.librarymanagement.ScalaArtifacts.isScala3
import scala.concurrent.duration._

Expand All @@ -12,7 +12,10 @@ ThisBuild / resolvers +=
"Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"

// CI Configuration
ThisBuild / githubWorkflowJavaVersions := Seq(JavaSpec.graalvm(Graalvm.Distribution("graalvm"), "17"), JavaSpec.temurin("8"))
ThisBuild / githubWorkflowJavaVersions := Seq(
JavaSpec.graalvm(Graalvm.Distribution("graalvm"), "17"),
JavaSpec.temurin("8"),
)
ThisBuild / githubWorkflowPREventTypes := Seq(
PREventType.Opened,
PREventType.Synchronize,
Expand Down Expand Up @@ -104,17 +107,28 @@ inThisBuild(

ThisBuild / githubWorkflowBuildTimeout := Some(60.minutes)

lazy val aggregatedProjects: Seq[ProjectReference] =
if (Shading.shadingEnabled) {
Seq(
zioHttp,
zioHttpTestkit,
)
} else {
Seq(
zioHttp,
zioHttpBenchmarks,
zioHttpCli,
zioHttpGen,
zioHttpExample,
zioHttpTestkit,
docs,
)
}

lazy val root = (project in file("."))
.settings(stdSettings("zio-http-root"))
.settings(publishSetting(false))
.aggregate(
zioHttp,
zioHttpBenchmarks,
zioHttpCli,
zioHttpExample,
zioHttpTestkit,
docs,
)
.aggregate(aggregatedProjects: _*)

lazy val zioHttp = (project in file("zio-http"))
.enablePlugins(Shading.plugins(): _*)
Expand Down Expand Up @@ -196,7 +210,7 @@ lazy val zioHttpBenchmarks = (project in file("zio-http-benchmarks"))
// "com.softwaremill.sttp.tapir" %% "tapir-akka-http-server" % "1.1.0",
"com.softwaremill.sttp.tapir" %% "tapir-http4s-server" % "1.5.1",
"com.softwaremill.sttp.tapir" %% "tapir-json-circe" % "1.5.1",
"com.softwaremill.sttp.client3" %% "core" % "3.9.0",
"com.softwaremill.sttp.client3" %% "core" % "3.9.1",
// "dev.zio" %% "zio-interop-cats" % "3.3.0",
"org.slf4j" % "slf4j-api" % "2.0.9",
"org.slf4j" % "slf4j-simple" % "2.0.9",
Expand Down Expand Up @@ -224,6 +238,19 @@ lazy val zioHttpExample = (project in file("zio-http-example"))
.settings(libraryDependencies ++= Seq(`jwt-core`))
.dependsOn(zioHttp, zioHttpCli)

lazy val zioHttpGen = (project in file("zio-http-gen"))
.settings(stdSettings("zio-http-gen"))
.settings(publishSetting(true))
.settings(
libraryDependencies ++= Seq(
`zio`,
`zio-test`,
`zio-test-sbt`,
scalafmt.cross(CrossVersion.for3Use2_13),
),
)
.dependsOn(zioHttp)

lazy val zioHttpTestkit = (project in file("zio-http-testkit"))
.enablePlugins(Shading.plugins(): _*)
.settings(stdSettings("zio-http-testkit"))
Expand Down
23 changes: 23 additions & 0 deletions docs/examples/advanced/static-files.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
id: static-files
title: "Serving Static Files"
sidebar_label: "Static Files"
---

```scala mdoc:silent
import zio._
import zio.http._

object StaticFiles extends ZIOAppDefault {

/**
* Creates an HTTP app that only serves static files from resources via
* "/static". For paths other than the resources directory, see
* [[Middleware.serveDirectory]].
*/
val app = Routes.empty.toHttpApp @@ Middleware.serveResources(Path.empty / "static")

override def run = Server.serve(app).provide(Server.default)
}

```
8 changes: 4 additions & 4 deletions project/BuildHelper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import de.heikoseeberger.sbtheader.HeaderPlugin.autoImport.{headerLicense, Heade

object BuildHelper extends ScalaSettings {
val Scala212 = "2.12.18"
val Scala213 = "2.13.10"
val Scala3 = "3.3.0"
val ScoverageVersion = "1.9.3"
val Scala213 = "2.13.12"
val Scala3 = "3.3.1"
val ScoverageVersion = "2.0.9"
val JmhVersion = "0.4.3"
val SilencerVersion = "1.17.13"
val SilencerVersion = "1.7.14"

private val stdOptions = Seq(
"-deprecation",
Expand Down
10 changes: 6 additions & 4 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@ import sbt.Keys.scalaVersion

object Dependencies {
val JwtCoreVersion = "9.1.1"
val NettyVersion = "4.1.100.Final"
val NettyIncubatorVersion = "0.0.20.Final"
val NettyVersion = "4.1.101.Final"
val NettyIncubatorVersion = "0.0.24.Final"
val ScalaCompactCollectionVersion = "2.11.0"
val ZioVersion = "2.0.18"
val ZioVersion = "2.0.19"
val ZioCliVersion = "0.5.0"
val ZioSchemaVersion = "0.4.14"
val ZioSchemaVersion = "0.4.16"
val SttpVersion = "3.3.18"

val `jwt-core` = "com.github.jwt-scala" %% "jwt-core" % JwtCoreVersion
val `scala-compact-collection` = "org.scala-lang.modules" %% "scala-collection-compat" % ScalaCompactCollectionVersion

val scalafmt = "org.scalameta" %% "scalafmt-dynamic" % "3.7.17"

val netty =
Seq(
"io.netty" % "netty-codec-http" % NettyVersion,
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.9.6
sbt.version=1.9.7
4 changes: 2 additions & 2 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.0")
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.6")
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.3")
addSbtPlugin("io.spray" % "sbt-revolver" % "0.10.0")
addSbtPlugin("com.github.sbt" % "sbt-github-actions" % "0.18.0")
addSbtPlugin("com.github.sbt" % "sbt-github-actions" % "0.19.0")
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12")
addSbtPlugin("dev.zio" % "zio-sbt-website" % "0.3.10")
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.10.0")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.8")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.9")
addSbtPlugin("io.get-coursier" % "sbt-shading" % "2.1.3")
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import zio.{Scope => _, _}
import zio.schema.{DeriveSchema, Schema}

import zio.http._
import zio.http.codec.{PathCodec, QueryCodec}
import zio.http.endpoint._
import zio.http.codec.QueryCodec
import zio.http.endpoint.Endpoint

import cats.effect.unsafe.implicits.global
import cats.effect.{IO => CIO}
Expand Down
30 changes: 16 additions & 14 deletions zio-http-cli/src/main/scala/zio/http/endpoint/cli/HttpOptions.scala
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package zio.http.endpoint.cli

import java.nio.file.Path

import scala.annotation.tailrec
import scala.language.implicitConversions
import scala.util.Try

import zio.cli._
import zio.json.ast._

import zio.schema._
import zio.schema.annotation.description

import zio.http._
import zio.http.codec._
Expand Down Expand Up @@ -241,8 +241,8 @@ private[cli] object HttpOptions {
self =>

override val name = pathCodec.segments.map {
case SegmentCodec.Literal(value, _) => value
case _ => ""
case SegmentCodec.Literal(value) => value
case _ => ""
}
.filter(_ != "")
.mkString("-")
Expand Down Expand Up @@ -300,7 +300,7 @@ private[cli] object HttpOptions {
Try(java.util.UUID.fromString(str)).toEither.left.map { error =>
ValidationError(
ValidationErrorType.InvalidValue,
HelpDoc.p(HelpDoc.Span.code(error.getMessage())),
HelpDoc.p(HelpDoc.Span.code(error.getMessage)),
)
},
)
Expand All @@ -312,27 +312,29 @@ private[cli] object HttpOptions {
}

private[cli] def optionsFromSegment(segment: SegmentCodec[_]): Options[String] = {
@tailrec
def fromSegment[A](segment: SegmentCodec[A]): Options[String] =
segment match {
case SegmentCodec.UUID(name, doc) =>
case SegmentCodec.UUID(name) =>
Options
.text(name)
.mapOrFail(str =>
Try(java.util.UUID.fromString(str)).toEither.left.map { error =>
ValidationError(
ValidationErrorType.InvalidValue,
HelpDoc.p(HelpDoc.Span.code(error.getMessage())),
HelpDoc.p(HelpDoc.Span.code(error.getMessage)),
)
},
)
.map(_.toString)
case SegmentCodec.Text(name, doc) => Options.text(name)
case SegmentCodec.IntSeg(name, doc) => Options.integer(name).map(_.toInt).map(_.toString)
case SegmentCodec.LongSeg(name, doc) => Options.integer(name).map(_.toInt).map(_.toString)
case SegmentCodec.BoolSeg(name, doc) => Options.boolean(name).map(_.toString)
case SegmentCodec.Literal(value, doc) => Options.Empty.map(_ => value)
case SegmentCodec.Trailing(doc) => Options.none.map(_.toString)
case SegmentCodec.Empty(_) => Options.none.map(_.toString)
case SegmentCodec.Text(name) => Options.text(name)
case SegmentCodec.IntSeg(name) => Options.integer(name).map(_.toInt).map(_.toString)
case SegmentCodec.LongSeg(name) => Options.integer(name).map(_.toInt).map(_.toString)
case SegmentCodec.BoolSeg(name) => Options.boolean(name).map(_.toString)
case SegmentCodec.Literal(value) => Options.Empty.map(_ => value)
case SegmentCodec.Trailing => Options.none.map(_.toString)
case SegmentCodec.Empty => Options.none.map(_.toString)
case SegmentCodec.Annotated(codec, _) => fromSegment(codec)
}

fromSegment(segment)
Expand Down

This file was deleted.

Loading

0 comments on commit 0b161cb

Please sign in to comment.