|
@@ -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)
|