chore: Migrate to GET variant of {{metadata_url}}/api/v1/metadata (#9994)

* chore: Migrate to GET variant of {{metadata_url}}/api/v1/metadata

* Fix test
docker-compose-changing-fe-port
nikitosing 7 months ago committed by GitHub
parent 934ad906e3
commit 8312379fbf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      apps/block_scout_web/test/block_scout_web/controllers/api/v2/address_controller_test.exs
  2. 15
      apps/explorer/lib/explorer/microservice_interfaces/metadata.ex

@ -1816,7 +1816,7 @@ defmodule BlockScoutWeb.API.V2.AddressControllerTest do
)
end)
Bypass.expect_once(bypass, "POST", "api/v1/metadata", fn conn ->
Bypass.expect_once(bypass, "GET", "api/v1/metadata", fn conn ->
Conn.resp(
conn,
200,

@ -19,27 +19,26 @@ defmodule Explorer.MicroserviceInterfaces.Metadata do
def get_addresses_tags(addresses) do
with :ok <- Microservice.check_enabled(__MODULE__) do
body = %{
addresses: addresses,
tags: %{
limit: to_string(@tags_per_address_limit)
}
addresses: Enum.join(addresses, ","),
tagsLimit: @tags_per_address_limit,
chainId: Application.get_env(:block_scout_web, :chain_id)
}
http_post_request(addresses_metadata_url(), body)
http_get_request(addresses_metadata_url(), body)
end
end
defp http_post_request(url, body) do
defp http_get_request(url, params) do
headers = [{"Content-Type", "application/json"}]
case HTTPoison.post(url, Jason.encode!(body), headers, recv_timeout: @post_timeout) do
case HTTPoison.get(url, headers, params: params, recv_timeout: @post_timeout) do
{:ok, %Response{body: body, status_code: 200}} ->
body |> Jason.decode() |> decode_meta()
{_, error} ->
Logger.error(fn ->
[
"Error while sending request to Metadata microservice url: #{url}, body: #{inspect(body)}: ",
"Error while sending request to Metadata microservice url: #{url}, params: #{inspect(params)}: ",
inspect(error)
]
end)

Loading…
Cancel
Save