Browse Source

Added Julia HTTP.jl framework (#6132)

* Added Julia HTTP.jl framework

* Fixed the travis build issue

* Added README
Sumeet Chhetri 4 years ago
parent
commit
f983a92f75

+ 1 - 0
.travis.yml

@@ -58,6 +58,7 @@ env:
     - 'TESTDIR="JavaScript/0http JavaScript/express JavaScript/fastify JavaScript/hapi JavaScript/koa"'
     - 'TESTDIR="JavaScript/0http JavaScript/express JavaScript/fastify JavaScript/hapi JavaScript/koa"'
     - 'TESTDIR="JavaScript/nodejs JavaScript/polkadot JavaScript/restana JavaScript/restify JavaScript/sailsjs"'
     - 'TESTDIR="JavaScript/nodejs JavaScript/polkadot JavaScript/restana JavaScript/restify JavaScript/sailsjs"'
     - 'TESTDIR="JavaScript/es4x JavaScript/ringojs JavaScript/just"'
     - 'TESTDIR="JavaScript/es4x JavaScript/ringojs JavaScript/just"'
+    - "TESTLANG=Julia"
     - "TESTLANG=Kotlin"
     - "TESTLANG=Kotlin"
     - "TESTLANG=Lisp"
     - "TESTLANG=Lisp"
     - "TESTLANG=Lua"
     - "TESTLANG=Lua"

+ 6 - 0
frameworks/Julia/Http.jl/README

@@ -0,0 +1,6 @@
+An implementation using the [HTTP.jl](https://github.com/JuliaWeb/HTTP.jl) package available for Julia
+
+For JSON support, the [JSON.jl](https://github.com/JuliaIO/JSON.jl) is used 
+
+Currently only the /json and /plaintext endpoints have been implemented
+

+ 25 - 0
frameworks/Julia/Http.jl/benchmark_config.json

@@ -0,0 +1,25 @@
+{
+	"framework": "http-jl",
+	"tests": [{
+		"default": {
+			"json_url": "/json",
+			"plaintext_url": "/plaintext",
+			"port": 8080,
+			"approach": "Realistic",
+			"classification": "None",
+			"database": "None",
+			"framework": "Http.jl",
+			"language": "Julia",
+			"orm": "None",
+			"platform": "None",
+			"webserver": "HTTP.jl",
+			"os": "Linux",
+			"database_os": "Linux",
+			"display_name": "Http.jl",
+			"notes": "",
+			"versus": "",
+			"tags": []
+		}
+	}]
+}
+

+ 34 - 0
frameworks/Julia/Http.jl/http-jl.dockerfile

@@ -0,0 +1,34 @@
+FROM ubuntu:20.04
+
+ENV IROOT=/installs
+
+ENV DEBIAN_FRONTEND noninteractive
+RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
+
+RUN apt update -yqq && apt-get install -y --reinstall ca-certificates
+RUN apt-get update -y && apt-get install -y --no-install-recommends wget
+
+RUN mkdir /usr/local/share/ca-certificates/cacert.org
+RUN wget -P /usr/local/share/ca-certificates/cacert.org http://www.cacert.org/certs/root.crt http://www.cacert.org/certs/class3.crt
+RUN update-ca-certificates
+#RUN git config --global http.sslCAinfo /etc/ssl/certs/ca-certificates.crt
+
+COPY server.jl ${IROOT}/
+WORKDIR ${IROOT}
+
+RUN wget -q https://julialang-s3.julialang.org/bin/linux/x64/1.5/julia-1.5.2-linux-x86_64.tar.gz
+RUN tar -xzf julia-1.5.2-linux-x86_64.tar.gz
+RUN mv julia-1.5.2 /opt/
+RUN rm -f julia-1.5.2-linux-x86_64.tar.gz
+ENV PATH="/opt/julia-1.5.2/bin:${PATH}"
+
+RUN julia -e 'import Pkg; Pkg.update()' && \
+    julia -e 'import Pkg; Pkg.add("HTTP")' && \
+    julia -e 'import Pkg; Pkg.add("JSON")' && \
+    julia -e 'import Pkg; Pkg.precompile()'
+
+COPY run.sh ${IROOT}/
+RUN chmod +x run.sh
+
+CMD ./run.sh
+

+ 6 - 0
frameworks/Julia/Http.jl/run.sh

@@ -0,0 +1,6 @@
+#!/bin/sh
+
+for i in $(seq 0 $(($(nproc --all)-1))); do
+	julia server.jl
+done
+

+ 23 - 0
frameworks/Julia/Http.jl/server.jl

@@ -0,0 +1,23 @@
+using HTTP
+using JSON
+using Dates
+
+HTTP.listen("0.0.0.0", 8080, reuseaddr=true) do http
+   HTTP.setheader(http, "Server" => "Julia-HTTP")
+   HTTP.setheader(http, "Date" => Dates.format(Dates.now(), Dates.RFC1123Format) * " GMT")
+   if endswith(http.message.target, "/plaintext")
+      HTTP.setheader(http, "Content-Type" => "text/plain")
+      HTTP.setstatus(http, 200)
+      startwrite(http)
+      write(http, "Hello, World!")
+   elseif endswith(http.message.target, "/json")
+      HTTP.setheader(http, "Content-Type" => "application/json")
+      HTTP.setstatus(http, 200)
+      startwrite(http)
+      write(http, JSON.json(Dict(:message => "Hello, World!")))
+   else
+       HTTP.setstatus(http, 404)
+       startwrite(http)
+       write(http, "Not Found")
+   end
+end