Improve gemini response field names
This commit is contained in:
parent
56fb4fe38c
commit
c5bbc439eb
|
@ -1,5 +1,5 @@
|
||||||
defmodule Chronoscope.Gemini.Response do
|
defmodule Chronoscope.Gemini.Response do
|
||||||
@response_pattern ~r/^(?<status>[0-9]{2}) (?<mime_type>.+)\r\n(?<body>(?s:.)*)/
|
@response_pattern ~r/^(?<status_code>[0-9]{2}) (?<meta>.+)\r\n(?<body>(?s:.)*)/
|
||||||
|
|
||||||
def parse(response) do
|
def parse(response) do
|
||||||
response
|
response
|
||||||
|
@ -14,7 +14,7 @@ defmodule Chronoscope.Gemini.Response do
|
||||||
|
|
||||||
match ->
|
match ->
|
||||||
match
|
match
|
||||||
|> Map.update!("status", &String.to_integer/1)
|
|> Map.update!("status_code", &String.to_integer/1)
|
||||||
|> to_atom_keys()
|
|> to_atom_keys()
|
||||||
|> then(&{:ok, &1})
|
|> then(&{:ok, &1})
|
||||||
end
|
end
|
||||||
|
|
|
@ -61,7 +61,7 @@ defmodule ChronoscopeWeb.API.V1.Gemini.ConnectionController do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp format_response(response) do
|
defp format_response(response) do
|
||||||
Map.take(response, [:status, :mime_type, :body, :cert_expiration])
|
Map.take(response, [:status_code, :meta, :body, :cert_expiration])
|
||||||
end
|
end
|
||||||
|
|
||||||
defp bad_request_response(conn, message) do
|
defp bad_request_response(conn, message) do
|
||||||
|
|
Loading…
Reference in New Issue