aboutsummaryrefslogtreecommitdiffstats
path: root/examples/elixir_hello_world/lib/elixir_hello_world
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2013-02-06 22:19:14 +0100
committerLoïc Hoguin <[email protected]>2013-02-06 22:19:14 +0100
commit37d24480236a5263eebbe957067f8698c78577f9 (patch)
tree73ddfccf3947c3e987ed21885431de1901d11668 /examples/elixir_hello_world/lib/elixir_hello_world
parent1c5ce11d13e7144091ce9a983ed0be6fbdb95c45 (diff)
parentb69903435e0278a6a91749d729f08ac01a8f623a (diff)
downloadcowboy-37d24480236a5263eebbe957067f8698c78577f9.tar.gz
cowboy-37d24480236a5263eebbe957067f8698c78577f9.tar.bz2
cowboy-37d24480236a5263eebbe957067f8698c78577f9.zip
Merge branch 'elixir-example' of git://github.com/yrashk/cowboy
Diffstat (limited to 'examples/elixir_hello_world/lib/elixir_hello_world')
-rw-r--r--examples/elixir_hello_world/lib/elixir_hello_world/supervisor.ex12
-rw-r--r--examples/elixir_hello_world/lib/elixir_hello_world/top_page_handler.ex12
2 files changed, 24 insertions, 0 deletions
diff --git a/examples/elixir_hello_world/lib/elixir_hello_world/supervisor.ex b/examples/elixir_hello_world/lib/elixir_hello_world/supervisor.ex
new file mode 100644
index 0000000..f9b569f
--- /dev/null
+++ b/examples/elixir_hello_world/lib/elixir_hello_world/supervisor.ex
@@ -0,0 +1,12 @@
+defmodule ElixirHelloWorld.Supervisor do
+ use Supervisor.Behaviour
+
+ def start_link do
+ :supervisor.start_link(__MODULE__, [])
+ end
+
+ def init([]) do
+ children = []
+ supervise children, strategy: :one_for_one
+ end
+end
diff --git a/examples/elixir_hello_world/lib/elixir_hello_world/top_page_handler.ex b/examples/elixir_hello_world/lib/elixir_hello_world/top_page_handler.ex
new file mode 100644
index 0000000..58e37b4
--- /dev/null
+++ b/examples/elixir_hello_world/lib/elixir_hello_world/top_page_handler.ex
@@ -0,0 +1,12 @@
+defmodule ElixirHelloWorld.TopPageHandler do
+ def init(_transport, req, []) do
+ {:ok, req, nil}
+ end
+
+ def handle(req, state) do
+ {:ok, req} = :cowboy_req.reply(200, [], "Hello world!", req)
+ {:ok, req, state}
+ end
+
+ def terminate(_reason, _req, _state), do: :ok
+end