diff --git a/frameworks/Scala/zio-http/.bsp/sbt.json b/frameworks/Scala/zio-http/.bsp/sbt.json new file mode 100644 index 00000000000..d7f7134e84d --- /dev/null +++ b/frameworks/Scala/zio-http/.bsp/sbt.json @@ -0,0 +1 @@ +{"name":"sbt","version":"1.5.5","bspVersion":"2.0.0-M5","languages":["scala"],"argv":["/Users/amitsingh/Library/Java/JavaVirtualMachines/openjdk-17/Contents/Home/bin/java","-Xms100m","-Xmx100m","-classpath","/Users/amitsingh/Library/Application Support/JetBrains/IdeaIC2021.3/plugins/Scala/launcher/sbt-launch.jar","xsbt.boot.Boot","-bsp","--sbt-launch-jar=/Users/amitsingh/Library/Application%20Support/JetBrains/IdeaIC2021.3/plugins/Scala/launcher/sbt-launch.jar"]} \ No newline at end of file diff --git a/frameworks/Scala/zio-http/.scalafmt.conf b/frameworks/Scala/zio-http/.scalafmt.conf new file mode 100644 index 00000000000..627fa67ec10 --- /dev/null +++ b/frameworks/Scala/zio-http/.scalafmt.conf @@ -0,0 +1,24 @@ +version = 3.2.1 +maxColumn = 120 + +align.preset = more +align.multiline = true +align.stripMargin = true + +continuationIndent.defnSite = 2 +assumeStandardLibraryStripMargin = true +danglingParentheses.preset = true +docstrings = JavaDoc +lineEndings = preserve +includeCurlyBraceInSelectChains = false +spaces.inImportCurlyBraces = false +optIn.annotationNewlines = true + +rewrite.rules = [SortImports, RedundantBraces, SortModifiers] +docstrings.wrap = yes +docstrings.style = Asterisk + +newlines.afterInfix = keep +rewrite.rules = [RedundantParens] +trailingCommas = "always" +runner.dialect = Scala213Source3 diff --git a/frameworks/Scala/zio-http/build.sbt b/frameworks/Scala/zio-http/build.sbt index 306bfecd28b..17ec27d747d 100644 --- a/frameworks/Scala/zio-http/build.sbt +++ b/frameworks/Scala/zio-http/build.sbt @@ -1,10 +1,9 @@ name := "zio-http" -version := "1.0.0" -scalaVersion := "2.13.6" +version := "1.0.0" +scalaVersion := "2.13.7" -lazy val zhttp = ProjectRef(uri(s"https://github.com/dream11/zio-http.git#---COMMIT_SHA---"), "zhttp") -lazy val root = (project in file(".")) +lazy val root = (project in file(".")) .settings( name := "helloExample", fork := true, @@ -12,15 +11,20 @@ lazy val root = (project in file(".")) Seq( "com.github.plokhotnyuk.jsoniter-scala" %% "jsoniter-scala-core" % "2.9.1", "com.github.plokhotnyuk.jsoniter-scala" %% "jsoniter-scala-macros" % "2.9.1" % "compile-internal", - "com.amazonaws" % "aws-java-sdk" % "1.11.500", - // "io.d11" % "zhttp" + "com.amazonaws" % "aws-java-sdk" % "1.11.500", + "io.d11" % "zhttp" % "1.0.0.0" from "file:///zhttp/zhttp-1.0.0.0.jar", ), - testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework") + testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework"), ) - .dependsOn(zhttp) assembly / assemblyMergeStrategy := { - case x if x.contains("io.netty.versions.properties") => MergeStrategy.discard - case x => + case PathList("META-INF", "io.netty.versions.properties") => MergeStrategy.discard + case x if x.contains("io/netty/util") => MergeStrategy.last + case x if x.contains("io/netty/handler") => MergeStrategy.last + case x if x.contains("io/netty/bootstrap") => MergeStrategy.last + case x if x.contains("io/netty/buffer") => MergeStrategy.last + case x if x.contains("io/netty/channel") => MergeStrategy.last + case x if x.contains("io/netty/resolver") => MergeStrategy.last + case x => val oldStrategy = (assembly / assemblyMergeStrategy).value oldStrategy(x) } diff --git a/frameworks/Scala/zio-http/src/main/scala/Main.scala b/frameworks/Scala/zio-http/src/main/scala/Main.scala index de799382bc1..261ae07be33 100644 --- a/frameworks/Scala/zio-http/src/main/scala/Main.scala +++ b/frameworks/Scala/zio-http/src/main/scala/Main.scala @@ -1,9 +1,6 @@ import zhttp.http._ import zhttp.service.{EventLoopGroup, Server} import zio.{App, ExitCode, URIO} -import com.github.plokhotnyuk.jsoniter_scala.macros._ -import com.github.plokhotnyuk.jsoniter_scala.core._ -import io.netty.buffer.Unpooled import io.netty.handler.codec.http.HttpHeaderNames import io.netty.util.AsciiString import zhttp.http.Response @@ -15,13 +12,9 @@ case class Message(message: String) object Main extends App { val message: String = "Hello, World!" - import io.netty.util.CharsetUtil - private val STATIC_PLAINTEXT = message.getBytes(CharsetUtil.UTF_8) private val STATIC_SERVER_NAME = AsciiString.cached("zio-http") - private val STATIC_PLAINTEXT_LEN = STATIC_PLAINTEXT.length - private val PLAINTEXT_CLHEADER_VALUE = AsciiString.cached(String.valueOf(STATIC_PLAINTEXT_LEN)) // Create HTTP route val app: HttpApp[Any, Nothing] = Http.response(Response.text(message).withServerTime.memoize.addHeader(HttpHeaderNames.SERVER, STATIC_SERVER_NAME)) val server = Server.app(app) ++ diff --git a/frameworks/Scala/zio-http/zio-http.dockerfile b/frameworks/Scala/zio-http/zio-http.dockerfile index f05ead620fe..36219968d81 100644 --- a/frameworks/Scala/zio-http/zio-http.dockerfile +++ b/frameworks/Scala/zio-http/zio-http.dockerfile @@ -4,6 +4,7 @@ WORKDIR /zhttp COPY src src COPY project project COPY build.sbt build.sbt +COPY zhttp-1.0.0.0.jar zhttp-1.0.0.0.jar RUN sbt assembly EXPOSE 8080