Browse Source

Add missing lib folder because someone set a global ignore

ext.bwaite 10 years ago
parent
commit
77a71ba614

+ 1 - 1
frameworks/Elixir/cowboy/benchmark_config.json

@@ -8,7 +8,7 @@
             "port": 8080,
             "port": 8080,
             "approach": "Realistic",
             "approach": "Realistic",
             "classification": "Platform",
             "classification": "Platform",
-            "database": "MySQL",
+            "database": "None",
             "framework": "cowboy",
             "framework": "cowboy",
             "language": "elixir",
             "language": "elixir",
             "orm": "raw",
             "orm": "raw",

+ 56 - 0
frameworks/Elixir/cowboy/lib/hello.ex

@@ -0,0 +1,56 @@
+defmodule Hello do
+
+  def start(_type, _args) do
+    dispatch = :cowboy_router.compile([
+
+      { :_,
+        [
+          {"/json", JsonHandler, []},
+          {"/plaintext", PlaintextHandler, []}
+      ]}
+    ])
+    { :ok, _ } = :cowboy.start_http(:http,
+                                    5000,
+                                   [{:port, 8080}],
+                                   [{ :env, [{:dispatch, dispatch}]}]
+                                   )
+  end
+end
+
+defmodule JsonHandler do
+  def init(_type, req, []) do
+    {:ok, req, :no_state}
+  end
+
+  def handle(request, state) do
+    Poison.encode!(%{message: "Hello, World!"})
+    { :ok, reply } = :cowboy_req.reply(200,
+      [{"content-type", "application/json"}],
+      Poison.encode!(%{:message => "Hello, World!"}),
+      request)
+    { :ok, reply, state }
+  end
+
+  def terminate(reason, request, state) do
+    :ok
+  end
+end
+
+defmodule PlaintextHandler do
+  def init(_type, req, []) do
+    {:ok, req, :no_state}
+  end
+
+  def handle(request, state) do
+    Poison.encode!(%{message: "Hello, World!"})
+    { :ok, reply } = :cowboy_req.reply(200,
+      [{"content-type", "text/plain"}],
+      "Hello, World!",
+      request)
+    { :ok, reply, state }
+  end
+
+  def terminate(reason, request, state) do
+    :ok
+  end
+end