Improve gemini response field names

This commit is contained in:
Mike Cifelli 2024-05-05 09:56:27 -04:00
parent 56fb4fe38c
commit c5bbc439eb
Signed by: mike
GPG Key ID: 6B08C6BE47D08E4C
2 changed files with 3 additions and 3 deletions

View File

@ -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

View File

@ -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