         readbody conn
     end
   end
+  
+  defp url(conn) do
+    "#{conn.scheme}://#{conn.host}:#{Integer.to_string(conn.port)}#{conn.request_path}?#{conn.query_string}"
+  end
+  
+  defp resp_headers(conn) do
+    conn.resp_headers
+    |> Enum.reduce(Map.new, fn {key, value}, acc ->
+      Map.put acc, key, value
+    end)
+  end
 end


  def pretty_json(conn, pretty) when pretty == true do
    {a, b, c, d} = conn.remote_ip
    headers =  conn.resp_headers
               |> Enum.reduce(Map.new, fn {key, value}, acc ->
                 Map.put acc, key, value
               end)

    request_url = "#{conn.scheme}://#{conn.host}:#{Integer.to_string(conn.port)}#{conn.request_path}?#{conn.query_string}"

    %HttpProxy.Data{
      request: %{
        url: request_url,
        remote: "#{a}.#{b}.#{c}.#{d}",
        method: conn.method,
        headers: conn.req_headers, # Maybe failed to convert

        body: conn.resp_body,
        cookies: conn.resp_cookies,
        status_code: conn.status,
        headers: resp_headers(conn)
      }
    }
    |> JSX.encode!
