I try to build a very simple REST API. It does not include a database or models.
Here's my router:
defmodule Zentonies.Router do
use Zentonies.Web, :router
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_flash
plug :protect_from_forgery
plug :put_secure_browser_headers
end
pipeline :api do
plug :accepts, ["json"]
end
scope "/v1/events/", Zentonies do
pipe_through :api
post "/call", PageController, :call
end
end
Here is the Controller:
defmodule Zentonies.PageController do
require Logger
import Joken
use Zentonies.Web, :controller
def index(conn, _params) do
render conn, "index.html"
end
def call(conn, params) do
Logger.debug inspect(params)
conn
|> put_status(200)
|> text("Response.")
end
end
Now, if I HTTP POST to this endpoint, inspect(params) does not return the JSON body of my POST request. Instead it returns the :call.
Any help is greatly appreciated!