Building the controller pipeline
Let’s start with the example controller we created in the previous chapter as part of an example for the Goldcrest.Controller
module:
lib/goldcrest/support/example_controller.ex
defmodule Goldcrest.ExampleController do import Plug.Conn import Goldcrest.Controller def call(conn, action: action) do apply(__MODULE__, action, [conn, conn.params]) end def greet(conn, _params) do conn |> put_status(200) |> render(:json, %{status: "ok"}) end # .. end
And just as in the previous chapter, we can start an HTTP server serving the preceding controller by running an iex
shell and loading the controller and router files:
$ iex -S mix iex> Code.require_file("./lib/goldcrest/support/example_controller.ex") iex> Code.require_file("./lib...