Browse Source

add: json tests "mofuw", and some update and edit. (#3794)

momf 7 years ago
parent
commit
4a79d82d80

+ 4 - 2
frameworks/Nim/mofuw/README.md

@@ -3,7 +3,9 @@
 > mofuw is \***MO**re\* \***F**\*aster, \***U**ltra\* \***W**\*eb server.
 > mofuw is \***MO**re\* \***F**\*aster, \***U**ltra\* \***W**\*eb server.
 
 
 ## Includes tests
 ## Includes tests
-- plaintext\: `"localhost:8080/plaintext"`
+- plaintext: `localhost:8080/plaintext`
+- json: `localhost:8080/json`
 
 
 ## Require
 ## Require
-- Nim 0.18.0 +
+- Nim => 0.18.0
+- mofuw => 1.1.8

+ 22 - 20
frameworks/Nim/mofuw/benchmark_config.json

@@ -1,22 +1,24 @@
 {
 {
-    "framework": "mofuw",
-    "tests": [{
-        "default": {
-            "plaintext_url": "/plaintext",
-            "port": 8080,
-            "approach": "Realistic",
-            "classification": "Micro",
-            "database": "None",
-            "framework": "mofuw",
-            "language": "Nim",
-            "orm": "Raw",
-            "platform": "None",
-            "webserver": "mofuw",
-            "os": "Linux",
-            "database_os": "Linux",
-            "display_name": "mofuw",
-            "notes": "",
-            "versus": ""
-        }
-    }]
+  "framework": "mofuw",
+  "tests": [{
+    "default": {
+      "json_url": "/json",
+      "plaintext_url": "/plaintext",
+      "port": 8080,
+      "approach": "Realistic",
+      "classification": "Platform",
+      "database": "MySQL",
+      "framework": "None",
+      "language": "Nim",
+      "flavor": "None",
+      "orm": "Raw",
+      "platform": "None",
+      "webserver": "None",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "mofuw",
+      "notes": "",
+      "versus": "Nim"
+    }
+  }]
 }
 }

+ 4 - 9
frameworks/Nim/mofuw/mofuw.dockerfile

@@ -1,4 +1,4 @@
-FROM gcc:7
+FROM gcc:latest
 
 
 RUN apt update -yqq &&                                                  \
 RUN apt update -yqq &&                                                  \
     mkdir -p /nim &&                                                    \
     mkdir -p /nim &&                                                    \
@@ -11,18 +11,13 @@ RUN apt update -yqq &&                                                  \
     cd ../ &&                                                           \
     cd ../ &&                                                           \
     bin/nim c koch &&                                                   \
     bin/nim c koch &&                                                   \
     ./koch boot -d:release &&                                           \
     ./koch boot -d:release &&                                           \
-    ./koch nimble &&                                                    \
     ./koch tools
     ./koch tools
 
 
 ENV PATH $PATH:/nim/nim-devel/bin:/root/.nimble/bin
 ENV PATH $PATH:/nim/nim-devel/bin:/root/.nimble/bin
 
 
-WORKDIR /mofu_framework
-RUN git clone https://github.com/2vg/mofuw.git && \
-    cd mofuw && \
-    nimble update && \
-    echo 'y' | nimble install
+RUN nimble install -y mofuw
 
 
-WORKDIR /mofuw_app
+WORKDIR /mofuwApp
 COPY techempower.nim techempower.nim
 COPY techempower.nim techempower.nim
-RUN nim c -d:release --threads:on techempower.nim
+RUN nim c -d:release --threads:on -d:bufSize:512 techempower.nim
 CMD ["./techempower"]
 CMD ["./techempower"]

+ 6 - 3
frameworks/Nim/mofuw/techempower.nim

@@ -1,9 +1,12 @@
-import mofuw
+import mofuw, json
 
 
 proc h(req: mofuwReq, res: mofuwRes) {.async.} =
 proc h(req: mofuwReq, res: mofuwRes) {.async.} =
-  if getPath(req) == "/plaintext":
+  case req.getPath
+  of "/plaintext":
     mofuwResp(HTTP200, "text/plain", "Hello, World!")
     mofuwResp(HTTP200, "text/plain", "Hello, World!")
+  of "/json":
+    mofuwResp(HTTP200, "application/json", $(%{"message": %"Hello, World!"}))
   else:
   else:
     mofuwResp(HTTP404, "text/plain", "NOT FOUND")
     mofuwResp(HTTP404, "text/plain", "NOT FOUND")
 
 
-h.mofuwRun(port = 8080, bufSize = 1024)
+h.mofuwRun(port = 8080)