diff options
author | William Carroll <wpcarro@gmail.com> | 2020-12-12T02·43+0000 |
---|---|---|
committer | William Carroll <wpcarro@gmail.com> | 2020-12-12T02·43+0000 |
commit | 8c5e4e77edacf082b5ab2d8aede49aa0ddfb9b5e (patch) | |
tree | b216303b8755d7d945a35a2a3d12d77b3828ceeb /assessments/semiprimes/server/lib/sup.ex | |
parent | 45877a8b9cbe728e2dd66c361b3d6625810b31a0 (diff) |
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.
Diffstat (limited to 'assessments/semiprimes/server/lib/sup.ex')
-rw-r--r-- | assessments/semiprimes/server/lib/sup.ex | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/assessments/semiprimes/server/lib/sup.ex b/assessments/semiprimes/server/lib/sup.ex index ea02ce30e7b9..13a6ab374ff6 100644 --- a/assessments/semiprimes/server/lib/sup.ex +++ b/assessments/semiprimes/server/lib/sup.ex @@ -5,6 +5,7 @@ defmodule Sup do """ use Supervisor + alias Plug.Adapters.Cowboy def start_link(opts \\ []) do Supervisor.start_link(__MODULE__, :ok, opts) @@ -13,7 +14,8 @@ defmodule Sup do @impl true def init(:ok) do children = [ - Cache + Cache, + Cowboy.child_spec(scheme: :http, plug: Router, options: [port: 8000]) ] Supervisor.init(children, strategy: :one_for_one) |