Browse Source

Add HttpBeast HTTP server. (#3912)

Dominik Picheta 7 years ago
parent
commit
ae89eb50eb

+ 16 - 0
frameworks/Nim/httpbeast/README.md

@@ -0,0 +1,16 @@
+# HttpBeast Benchmarking Test
+
+## Important Libraries
+
+The tests were run with:
+
+* [HttpBeast](https://github.com/dom96/httpbeast)
+
+## Test URLs
+### JSON
+
+http://localhost:8080/json
+
+### PLAINTEXT
+
+http://localhost:8080/plaintext

+ 26 - 0
frameworks/Nim/httpbeast/benchmark_config.json

@@ -0,0 +1,26 @@
+{
+  "framework": "httpbeast",
+  "tests": [
+    {
+      "default": {
+        "json_url": "/json",
+        "plaintext_url": "/plaintext",
+        "port": 8080,
+        "approach": "Realistic",
+        "classification": "Platform",
+        "database": "None",
+        "framework": "None",
+        "language": "Nim",
+        "flavor": "None",
+        "orm": "None",
+        "platform": "None",
+        "webserver": "None",
+        "os": "Linux",
+        "database_os": "Linux",
+        "display_name": "HttpBeast",
+        "notes": "",
+        "versus": "None"
+      }
+    }
+  ]
+}

+ 14 - 0
frameworks/Nim/httpbeast/httpbeast.dockerfile

@@ -0,0 +1,14 @@
+FROM gcc:latest
+
+RUN apt update && apt install -y libgc-dev
+
+ENV CHOOSENIM_NO_ANALYTICS 1
+ENV CHOOSENIM_CHOOSE_VERSION #0c683d28bbd5
+RUN curl https://nim-lang.org/choosenim/init.sh -sSf | sh -s -- -y
+ENV PATH $PATH:/root/.nimble/bin
+
+ADD ./ /httpbeast
+WORKDIR /httpbeast
+RUN nimble c -d:release --gc:boehm -y techempower.nim
+
+CMD ./techempower

+ 19 - 0
frameworks/Nim/httpbeast/techempower.nim

@@ -0,0 +1,19 @@
+import options, asyncdispatch, json
+
+import httpbeast
+
+proc onRequest(req: Request): Future[void] =
+  if req.httpMethod == some(HttpGet):
+    case req.path.get()
+    of "/json":
+      const data = $(%*{"message": "Hello, World!"})
+      const headers = "Content-Type: application/json"
+      req.send(Http200, data, headers)
+    of "/plaintext":
+      const data = "Hello, World!"
+      const headers = "Content-Type: text/plain"
+      req.send(Http200, data, headers)
+    else:
+      req.send(Http404)
+
+run(onRequest)

+ 14 - 0
frameworks/Nim/httpbeast/techempower.nimble

@@ -0,0 +1,14 @@
+# Package
+
+version       = "0.1.0"
+author        = "Dominik Picheta"
+description   = "TechEmpower HttpBeast benchmark."
+license       = "MIT"
+
+bin           = @["techempower"]
+skipExt = @["nim"]
+
+# Dependencies
+
+requires "nim >= 0.18.0"
+requires "httpbeast#95a753b99d0059"