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.
This commit is contained in:
parent
45877a8b9c
commit
8c5e4e77ed
4 changed files with 104 additions and 2 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue