Skip to content
Permalink
Browse files

Code for step 2

  • Loading branch information...
akoutmos committed Jul 19, 2019
1 parent 8c98aa4 commit fc8cdbc1bca93b00d567e8b34c0701fe2a30fd99
Showing with 21 additions and 3 deletions.
  1. +18 −0 lib/sentry_sample_app_web/controllers/math_controller.ex
  2. +3 −3 lib/sentry_sample_app_web/router.ex
@@ -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
@@ -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.

0 comments on commit fc8cdbc

Please sign in to comment.
You can’t perform that action at this time.