defmodule Grazer.Net do use GenServer def start_link(arg) do GenServer.start_link(__MODULE__, arg, name: __MODULE__) end def request(req) do GenServer.cast(__MODULE__, [req: req]) end @impl true def init(_init_arg) do {:ok, []} end @impl true def handle_cast([req: [get: url, for: whom]], state) do http_opts = [body_format: :binary] {:ok, resp} = :httpc.request(:get, {url, []}, [], http_opts) send(whom, [resp: resp]) {:noreply, state} end end