Skip to content

Commit

Permalink
The endpoint exists
Browse files Browse the repository at this point in the history
  • Loading branch information
philosodad committed Feb 21, 2016
1 parent 5201dda commit 2229fcf
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
/deps
erl_crash.dump
*.ez
*.swp
17 changes: 17 additions & 0 deletions lib/loggex.ex
Original file line number Diff line number Diff line change
@@ -1,2 +1,19 @@
defmodule Loggex do
require IEx
use Plug.Router

plug :match
plug :dispatch

def start do
Plug.Adapters.Cowboy.http Loggex, [], port: 6438
end

def stop do
Plug.Adapters.Cowboy.shutdown Loggex.HTTP
end
post "/log" do
send_resp(conn, 200, "No Response")
end

end
12 changes: 10 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ defmodule Loggex.Mixfile do
#
# Type "mix help compile.app" for more information
def application do
[applications: [:logger, :cowboy, :plug, :postgrex, :ecto]]
[applications: [:logger, :cowboy, :plug, :postgrex, :ecto, :httpoison]]
end

# Dependencies can be Hex packages:
Expand All @@ -27,6 +27,14 @@ defmodule Loggex.Mixfile do
#
# Type "mix help deps" for more examples and options
defp deps do
[]
[
{:httpoison, "~> 0.8.0"},
{:cowboy, "~> 1.0.0"},
{:plug, "~> 1.0"},
{:exjsx, "~> 3.2"},
{:postgrex, ">= 0.0.0"},
{:ecto, "~> 1.1.2"},
{:uuid, "~> 0.1.1"}
]
end
end
19 changes: 19 additions & 0 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
%{"certifi": {:hex, :certifi, "0.3.0"},
"connection": {:hex, :connection, "1.0.2"},
"cowboy": {:hex, :cowboy, "1.0.4"},
"cowlib": {:hex, :cowlib, "1.0.2"},
"db_connection": {:hex, :db_connection, "0.2.3"},
"decimal": {:hex, :decimal, "1.1.1"},
"ecto": {:hex, :ecto, "1.1.3"},
"exjsx": {:hex, :exjsx, "3.2.0"},
"hackney": {:hex, :hackney, "1.4.8"},
"httpoison": {:hex, :httpoison, "0.8.1"},
"idna": {:hex, :idna, "1.0.3"},
"jsx": {:hex, :jsx, "2.6.2"},
"mimerl": {:hex, :mimerl, "1.0.2"},
"plug": {:hex, :plug, "1.1.1"},
"poolboy": {:hex, :poolboy, "1.5.1"},
"postgrex": {:hex, :postgrex, "0.11.1"},
"ranch": {:hex, :ranch, "1.2.1"},
"ssl_verify_hostname": {:hex, :ssl_verify_hostname, "1.0.5"},
"uuid": {:hex, :uuid, "0.1.5"}}
16 changes: 14 additions & 2 deletions test/loggex_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,19 @@ defmodule LoggexTest do
use ExUnit.Case
doctest Loggex

test "the truth" do
assert 1 + 1 == 2
#test the start method of loggex
#start should start the server

setup do
Loggex.start
on_exit fn ->
Loggex.stop
end
:ok
end

test "route exists" do
{:ok, response} = HTTPoison.post "localhost:6438/log", "", []
assert response.status_code == 200
end
end

0 comments on commit 2229fcf

Please sign in to comment.