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

jar poc #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions frameworks/Scala/zio-http/.bsp/sbt.json
Original file line number Diff line number Diff line change
@@ -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"]}
24 changes: 24 additions & 0 deletions frameworks/Scala/zio-http/.scalafmt.conf
Original file line number Diff line number Diff line change
@@ -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
24 changes: 14 additions & 10 deletions frameworks/Scala/zio-http/build.sbt
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
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,
libraryDependencies ++=
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)
}
7 changes: 0 additions & 7 deletions frameworks/Scala/zio-http/src/main/scala/Main.scala
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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) ++
Expand Down
1 change: 1 addition & 0 deletions frameworks/Scala/zio-http/zio-http.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down