mirror of
https://github.com/edgurgel/httparrot
synced 2025-04-06 00:32:34 -04:00
Remove unsafe variable warning
This commit is contained in:
parent
d4e826cd5b
commit
62f01ffd9a
1 changed files with 8 additions and 7 deletions
|
@ -58,12 +58,13 @@ defmodule HTTParrot do
|
||||||
def stop(_State), do: :ok
|
def stop(_State), do: :ok
|
||||||
|
|
||||||
def prettify_json(status, headers, body, req) do
|
def prettify_json(status, headers, body, req) do
|
||||||
if JSX.is_json? body do
|
case JSX.is_json?(body) do
|
||||||
|
true ->
|
||||||
body = JSX.prettify!(body)
|
body = JSX.prettify!(body)
|
||||||
headers = List.keystore(headers, "content-length", 0, {"content-length", Integer.to_char_list(String.length(body))})
|
headers = List.keystore(headers, "content-length", 0, {"content-length", Integer.to_char_list(String.length(body))})
|
||||||
{:ok, req} = :cowboy_req.reply(status, headers, body, req)
|
{:ok, pretty_req} = :cowboy_req.reply(status, headers, body, req)
|
||||||
req
|
pretty_req
|
||||||
else
|
_ ->
|
||||||
req
|
req
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue