Browse Source

Update SNUnit Scala to 0.0.17 (#7305)

Lorenzo Gabriele 3 years ago
parent
commit
d2dcff80e4

+ 3 - 4
frameworks/Scala/snunit/build.sbt

@@ -1,12 +1,11 @@
 import scala.scalanative.build._
 
-scalaVersion := "2.13.7"
+scalaVersion := "2.13.8"
 
-val snunitVersion = "0.0.11"
+val snunitVersion = "0.0.17"
 libraryDependencies ++= Seq(
   "com.github.lolgab" %%% "snunit" % snunitVersion,
-  "com.github.lolgab" %%% "snunit-async" % snunitVersion,
-  "com.lihaoyi" %%% "upickle" % "1.4.2"
+  "com.lihaoyi" %%% "upickle" % "1.6.0"
 )
 
 nativeConfig ~= {

+ 1 - 1
frameworks/Scala/snunit/project/build.properties

@@ -1 +1 @@
-sbt.version=1.5.5
+sbt.version=1.6.2

+ 1 - 1
frameworks/Scala/snunit/project/plugins.sbt

@@ -1 +1 @@
-addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.2")
+addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.4")

+ 1 - 3
frameworks/Scala/snunit/snunit.dockerfile

@@ -6,7 +6,7 @@ RUN apt-get update && apt-get install -y curl gnupg && \
   curl -sL https://nginx.org/keys/nginx_signing.key | apt-key add - && \
   echo "deb https://packages.nginx.org/unit/debian/ bullseye unit" > /etc/apt/sources.list.d/unit.list && \
   echo "deb-src https://packages.nginx.org/unit/debian/ bullseye unit" >> /etc/apt/sources.list.d/unit.list && \
-  apt-get update && apt-get install -y clang unit-dev libuv1-dev openjdk-11-jdk sbt && \
+  apt-get update && apt-get install -y clang unit-dev openjdk-11-jdk sbt && \
   apt-get purge -y gnupg
 
 WORKDIR /workdir
@@ -17,8 +17,6 @@ RUN sbt nativeLink
 
 FROM nginx/unit:1.26.1-minimal
 
-RUN apt-get update && apt-get install -y libuv1
-
 COPY /config.sh /docker-entrypoint.d/
 COPY --from=builder /workdir/target/scala-2.13/workdir-out /app/example
 

+ 6 - 5
frameworks/Scala/snunit/src/main/scala/Main.scala

@@ -9,8 +9,8 @@ object Message {
 
 object Main {
   def main(args: Array[String]): Unit = {
-    AsyncServerBuilder()
-      .withRequestHandler(req =>
+    val server = SyncServerBuilder
+      .build(req =>
         if (req.method == Method.GET && req.path == "/plaintext")
           req.send(
             statusCode = StatusCode.OK,
@@ -20,8 +20,8 @@ object Main {
         else if (req.method == Method.GET && req.path == "/json")
           req.send(
             statusCode = StatusCode.OK,
-            content = stream(Message("Hello, World!")),
-            headers = Seq.empty
+            content = write(Message("Hello, World!")),
+            headers = Seq("Content-Type" -> "application/json")
           )
         else
           req.send(
@@ -30,6 +30,7 @@ object Main {
             headers = Seq("Content-Type" -> "text/plain")
           )
       )
-      .build()
+
+    server.listen()
   }
 }