Skip to content

Commit 9f3ba2c

Browse files
authored
Merge pull request #2193 from poanetwork/add_runtime_configured_host
feat: add BLOCKSCOUT_HOST, and use it in API docs
2 parents b99c978 + d47cb2b commit 9f3ba2c

File tree

5 files changed

+14
-5
lines changed

5 files changed

+14
-5
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- [#2151](https://github.com/poanetwork/blockscout/pull/2151) - hide dropdown menu then other networks list is empty
77
- [#2191](https://github.com/poanetwork/blockscout/pull/2191) - allow to configure token metadata update interval
88
- [#2146](https://github.com/poanetwork/blockscout/pull/2146) - feat: add eth_getLogs rpc endpoint
9+
- [#2193](https://github.com/poanetwork/blockscout/pull/2193) - feat: add BLOCKSCOUT_HOST, and use it in API docs
910

1011
### Fixes
1112
- [#2238](https://github.com/poanetwork/blockscout/pull/2238) - header content alignment issue, hide navbar on outside click

apps/block_scout_web/config/config.exs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ config :block_scout_web, BlockScoutWeb.Endpoint,
4141
]
4242
],
4343
url: [
44-
host: "localhost",
44+
host: System.get_env("BLOCKSCOUT_HOST") || "localhost",
4545
path: System.get_env("NETWORK_PATH") || "/"
4646
],
4747
render_errors: [view: BlockScoutWeb.ErrorView, accepts: ~w(html json)],

apps/block_scout_web/lib/block_scout_web/templates/api_docs/eth_rpc.html.eex

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
<div class="card">
33
<div class="card-body">
44
<h1 class="card-title margin-bottom-sm"><%= gettext("ETH RPC API Documentation") %></h2>
5-
<p class="api-text-monospace" data-endpoint-url="<%= BlockScoutWeb.Endpoint.url() %>/api/eth_rpc">[ <%= gettext "Base URL:" %> <%= @conn.host %>/api/eth_rpc ]</p>
5+
<p class="api-text-monospace" data-endpoint-url="<%= BlockScoutWeb.Endpoint.url() %>/api/eth_rpc">[ <%= gettext "Base URL:" %> <%= url() %>/api/eth_rpc ]</p>
66
<p class="card-subtitle margin-bottom-0">
7-
<%= gettext "This API is provided to support some rpc methods in the exact format specified for ethereum nodes, which can be found " %>
7+
<%= gettext "This API is provided to support some rpc methods in the exact format specified for ethereum nodes, which can be found " %>
88

99
<a href="https://github.com/ethereum/wiki/wiki/JSON-RPC"><%= gettext "here." %></a>
1010
<%= gettext "This is useful to allow sending requests to blockscout without having to change anything about the request." %>

apps/block_scout_web/lib/block_scout_web/templates/api_docs/index.html.eex

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="card">
33
<div class="card-body">
44
<h1 class="card-title margin-bottom-sm"><%= gettext("API Documentation") %></h2>
5-
<p class="api-text-monospace" data-endpoint-url="<%= BlockScoutWeb.Endpoint.url() %>/api">[ <%= gettext "Base URL:" %> <%= @conn.host %>/api ]</p>
5+
<p class="api-text-monospace" data-endpoint-url="<%= BlockScoutWeb.Endpoint.url() %>/api">[ <%= gettext "Base URL:" %> <%= url() %>/api ]</p>
66
<p class="card-subtitle margin-bottom-0"><%= gettext "This API is provided for developers transitioning their applications from Etherscan to BlockScout. It supports GET and POST requests." %></p>
77
</div>
88
<div class="api-anchors-list">

apps/block_scout_web/lib/block_scout_web/views/api_docs_view.ex

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defmodule BlockScoutWeb.APIDocsView do
22
use BlockScoutWeb, :view
33

4-
alias BlockScoutWeb.LayoutView
4+
alias BlockScoutWeb.{Endpoint, LayoutView}
55

66
def action_tile_id(module, action) do
77
"#{module}-#{action}"
@@ -33,4 +33,12 @@ defmodule BlockScoutWeb.APIDocsView do
3333
"&#{param.key}=" <> "{<strong>#{param.placeholder}</strong>}"
3434
end)
3535
end
36+
37+
defp url do
38+
if System.get_env("BLOCKSCOUT_HOST") do
39+
"http://" <> System.get_env("BLOCKSCOUT_HOST")
40+
else
41+
Endpoint.url()
42+
end
43+
end
3644
end

0 commit comments

Comments
 (0)