defmodule ReverseProxy.Service do @moduledoc """ This is the brains of our app. Everything from the `Router` gets sent here and gets resent to the runner that retreives the contents from the host. This is the place to stack other middleware we want. We need this abstraction in order to be able to cache responses. Here is the place to decide whether we hit the cache or do a request. """ @behaviour Plug def init(opts), do: opts def call(conn, opts) do upstream = Keyword.get(opts, :upstream, []) ReverseProxy.Runner.retreive(conn, upstream) end end