From 9bd6c41cd78683491482b487a98a6f8a917cf2e7 Mon Sep 17 00:00:00 2001 From: klevialent Date: Sat, 9 Nov 2024 19:34:56 +0300 Subject: [PATCH] pass plug call options --- README.md | 2 +- lib/main_proxy/plug.ex | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8860b8f..e6c9f35 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,7 @@ config :my_app_members, MyAppMembersWeb.Endpoint, server: false - `:host` - `:path` - `:phoenix_endpoint` / `:plug` - - `:opts` - only for `:plug` + - `:opts` - plug call options. - `:log_requests` - `true` by default. Log the requests or not. diff --git a/lib/main_proxy/plug.ex b/lib/main_proxy/plug.ex index 5f11145..3decacb 100644 --- a/lib/main_proxy/plug.ex +++ b/lib/main_proxy/plug.ex @@ -13,11 +13,12 @@ defmodule MainProxy.Plug do backends = Keyword.fetch!(opts, :backends) backend = choose_backend(conn, backends) + opts = Map.get(backend, :opts, []) log_request("Backend chosen: #{inspect(backend)}") case backend do - %{phoenix_endpoint: phoenix_endpoint} -> phoenix_endpoint.call(conn, []) - %{plug: plug} -> plug.call(conn, []) + %{phoenix_endpoint: phoenix_endpoint} -> phoenix_endpoint.call(conn, opts) + %{plug: plug} -> plug.call(conn, opts) end end