Skip to content

Commit

Permalink
Code for step 2
Browse files Browse the repository at this point in the history
  • Loading branch information
akoutmos committed Jul 19, 2019
1 parent 8c98aa4 commit fc8cdbc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
18 changes: 18 additions & 0 deletions lib/sentry_sample_app_web/controllers/math_controller.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
defmodule SentrySampleAppWeb.MathController do
use SentrySampleAppWeb, :controller

def create(conn, %{"function" => "add", "val_1" => val_1, "val_2" => val_2}) do
conn
|> json(%{result: val_1 + val_2})
end

def create(conn, %{"function" => "div", "val_1" => val_1, "val_2" => val_2}) do
conn
|> json(%{result: val_1 / val_2})
end

def create(conn, %{"function" => "mult", "val_1" => val_1, "val_2" => val_2}) do
conn
|> json(%{result: val_1 * val_2})
end
end
6 changes: 3 additions & 3 deletions lib/sentry_sample_app_web/router.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ defmodule SentrySampleAppWeb.Router do
plug :accepts, ["json"]
end

scope "/", SentrySampleAppWeb do
pipe_through :browser
scope "/math", SentrySampleAppWeb do
pipe_through :api

get "/", PageController, :index
post "/", MathController, :create
end

# Other scopes may use custom stacks.
Expand Down

0 comments on commit fc8cdbc

Please sign in to comment.