Skip to content

Commit 292ffa3

Browse files
committed
Use standard library to convert from iodata
1 parent 9c1543b commit 292ffa3

1 file changed

Lines changed: 1 addition & 19 deletions

File tree

lib/swapi_web/wookiee_encoder.ex

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -64,29 +64,11 @@ defmodule SWAPIWeb.WookieeEncoder do
6464
defp before_send_callback(%{status: 200} = conn) do
6565
wookie_body =
6666
conn.resp_body
67-
|> flatten_body()
67+
|> IO.iodata_to_binary()
6868
|> translate_to_wookiee()
6969

7070
resp(conn, conn.status, wookie_body)
7171
end
7272

7373
defp before_send_callback(conn), do: conn
74-
75-
defp flatten_list_improper(list) do
76-
case list do
77-
[] -> []
78-
[h | t] when is_list(h) -> flatten_list_improper(h) ++ flatten_list_improper(t)
79-
[h | t] -> [h | flatten_list_improper(t)]
80-
scalar -> [scalar]
81-
end
82-
end
83-
84-
defp flatten_body(list) do
85-
list
86-
|> flatten_list_improper()
87-
|> Enum.map_join("", fn
88-
x when is_integer(x) -> <<x::utf8>>
89-
x -> x
90-
end)
91-
end
9274
end

0 commit comments

Comments
 (0)