Skip to content

Commit

Permalink
Merge pull request #1 from d0rc/master
Browse files Browse the repository at this point in the history
Fixes to make example work with modern cowboy/elixir 0.7
  • Loading branch information
clofresh committed Oct 28, 2012
2 parents d33288a + 2576f19 commit 330e204
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Expand Up @@ -12,6 +12,6 @@ task :dependencies do
end

task :start do
sh "erl -pa ebin/ -pa deps/*/ebin/ -s elixir_cowboy"
sh "elixir --erl 'erl -pa ebin/ -pa deps/*/ebin/ -s elixir_cowboy' --no-halt"
end

17 changes: 10 additions & 7 deletions src/elixir_cowboy.ex
Expand Up @@ -2,17 +2,20 @@ defmodule :elixir_cowboy do
@behavior :application

def start() do
Erlang.application.start(:cowboy)
Erlang.application.start(:elixir_cowboy)
IO.puts("Starting up")
:application.start(:crypto)
:application.start(:ranch)
:application.start(:cowboy)
:application.start(:elixir_cowboy)
end

def start(_type, _args) do
dispatch = [
{:'_', [{:'_', :elixir_cowboy_handler, []}]}
]
Erlang.cowboy.start_listener(:my_http_listener, 100,
:cowboy_tcp_transport, [{:port, 8080}],
:cowboy_http_protocol, [{:dispatch, dispatch}]
:cowboy.start_http(:my_http_listener, 100,
[{:port, 8080}],
[{:dispatch, dispatch}]
)
end

Expand All @@ -29,7 +32,7 @@ defmodule :elixir_cowboy_handler do
end

def handle(req, state) do
{:ok, req2} = Erlang.cowboy_http_req.reply(200, [], "Hello world!", req)
{:ok, req2} = :cowboy_req.reply(200, [], "Hello world!", req)
{:ok, req2, state}
end

Expand All @@ -43,7 +46,7 @@ defmodule :elixir_cowboy_sup do
@behavior :supervisor

def start_link() do
Erlang.supervisor.start_link({:local, :elixir_cowboy_sup}, :elixir_cowboy_sup, [])
:supervisor.start_link({:local, :elixir_cowboy_sup}, :elixir_cowboy_sup, [])
end

def init([]) do
Expand Down

0 comments on commit 330e204

Please sign in to comment.