@@ -519,16 +519,9 @@ defmodule Phoenix.Sync.Electric do
519519 end
520520
521521 defp http_mode_plug_opts ( electric_config ) do
522- with { :ok , url } <- fetch_with_error ( electric_config , :url ) ,
523- credential_params = electric_config |> Keyword . get ( :credentials , [ ] ) |> Map . new ( ) ,
524- extra_params = electric_config |> Keyword . get ( :params , [ ] ) |> Map . new ( ) ,
525- params = Map . merge ( extra_params , credential_params ) ,
526- { :ok , client } <-
527- Electric.Client . new (
528- base_url: url ,
529- params: params ,
530- fetch: { Electric.Client.Fetch.HTTP , [ request: [ raw: true ] ] }
531- ) do
522+ with { :ok , client } <- configure_client ( electric_config , :http ) do
523+ # don't decode the body - just pass it directly
524+ client = % { client | fetch: { Electric.Client.Fetch.HTTP , [ request: [ raw: true ] ] } }
532525 { :ok , % Phoenix.Sync.Electric.ClientAdapter { client: client } }
533526 end
534527 end
@@ -543,13 +536,15 @@ defmodule Phoenix.Sync.Electric do
543536 end
544537 end
545538
546- defp configure_client ( opts , :http ) do
547- case Keyword . fetch ( opts , :url ) do
548- { :ok , url } ->
549- Electric.Client . new ( base_url: url )
550-
551- :error ->
552- { :error , "`phoenix_sync[:electric][:url]` not set for phoenix_sync in HTTP mode" }
539+ defp configure_client ( electric_config , :http ) do
540+ with { :ok , url } <- fetch_with_error ( electric_config , :url ) ,
541+ credential_params = electric_config |> Keyword . get ( :credentials , [ ] ) |> Map . new ( ) ,
542+ extra_params = electric_config |> Keyword . get ( :params , [ ] ) |> Map . new ( ) ,
543+ params = Map . merge ( extra_params , credential_params ) do
544+ Electric.Client . new (
545+ base_url: url ,
546+ params: params
547+ )
553548 end
554549 end
555550end
0 commit comments