tvl-depot/assessments/semiprimes/server/lib/sup.ex
William Carroll 8c5e4e77ed Expose functions at API layer
Creating a simple HTTP RESTful API for exposing our `Server.semiprime`
function. It supports some help messages, primitive parsing and error handling,
and singular vs. batch processing of arguments.

For more sophisticated parsing and error-checking, I prefer to use Haskell's
Servant library.
2020-12-12 02:43:40 +00:00

23 lines
491 B
Elixir

defmodule Sup do
@moduledoc """
Top-level supervisor for our OTP application. For now, this supervisor starts
and monitors our cache.
"""
use Supervisor
alias Plug.Adapters.Cowboy
def start_link(opts \\ []) do
Supervisor.start_link(__MODULE__, :ok, opts)
end
@impl true
def init(:ok) do
children = [
Cache,
Cowboy.child_spec(scheme: :http, plug: Router, options: [port: 8000])
]
Supervisor.init(children, strategy: :one_for_one)
end
end