Skip to content

Commit

Permalink
Remove syntax to be future deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Nov 8, 2024
1 parent d79ed21 commit 6c4ef6e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions lib/phoenix/controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1094,7 +1094,7 @@ defmodule Phoenix.Controller do
conn
else
content_type = content_type <> "; charset=utf-8"
%Plug.Conn{conn | resp_headers: [{"content-type", content_type} | resp_headers]}
%{conn | resp_headers: [{"content-type", content_type} | resp_headers]}
end
end

Expand Down Expand Up @@ -1323,15 +1323,15 @@ defmodule Phoenix.Controller do
"""
@spec scrub_params(Plug.Conn.t(), String.t()) :: Plug.Conn.t()
def scrub_params(conn, required_key) when is_binary(required_key) do
def scrub_params(%Plug.Conn{} = conn, required_key) when is_binary(required_key) do
param = Map.get(conn.params, required_key) |> scrub_param()

unless param do
raise Phoenix.MissingParamError, key: required_key
end

params = Map.put(conn.params, required_key, param)
%Plug.Conn{conn | params: params}
%{conn | params: params}
end

defp scrub_param(%{__struct__: mod} = struct) when is_atom(mod) do
Expand Down
10 changes: 5 additions & 5 deletions lib/phoenix/endpoint/render_errors.ex
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ defmodule Phoenix.Endpoint.RenderErrors do
end

@doc false
def __catch__(conn, kind, reason, stack, opts) do
def __catch__(%Plug.Conn{} = conn, kind, reason, stack, opts) do
conn =
receive do
@already_sent ->
send(self(), @already_sent)
%Plug.Conn{conn | state: :sent}
%{conn | state: :sent}
after
0 ->
instrument_render_and_send(conn, kind, reason, stack, opts)
Expand Down Expand Up @@ -126,13 +126,13 @@ defmodule Phoenix.Endpoint.RenderErrors do
Controller.render(conn, template, assigns)
end

defp maybe_fetch_query_params(conn) do
defp maybe_fetch_query_params(%Plug.Conn{} = conn) do
fetch_query_params(conn)
rescue
Plug.Conn.InvalidQueryError ->
case conn.params do
%Plug.Conn.Unfetched{} -> %Plug.Conn{conn | query_params: %{}, params: %{}}
params -> %Plug.Conn{conn | query_params: %{}, params: params}
%Plug.Conn.Unfetched{} -> %{conn | query_params: %{}, params: %{}}
params -> %{conn | query_params: %{}, params: params}
end
end

Expand Down

0 comments on commit 6c4ef6e

Please sign in to comment.