|
|
@ -1,11 +1,19 @@ |
|
|
|
|
|
|
|
defmodule RPCTranslatorForwarder do |
|
|
|
|
|
|
|
@moduledoc """ |
|
|
|
|
|
|
|
Phoenix router limits forwarding, |
|
|
|
|
|
|
|
so this module is to forward old paths for backward compatibility |
|
|
|
|
|
|
|
""" |
|
|
|
|
|
|
|
alias BlockScoutWeb.API.RPC.RPCTranslator |
|
|
|
|
|
|
|
defdelegate init(opts), to: RPCTranslator |
|
|
|
|
|
|
|
defdelegate call(conn, opts), to: RPCTranslator |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
defmodule BlockScoutWeb.ApiRouter do |
|
|
|
defmodule BlockScoutWeb.ApiRouter do |
|
|
|
@moduledoc """ |
|
|
|
@moduledoc """ |
|
|
|
Router for API |
|
|
|
Router for API |
|
|
|
""" |
|
|
|
""" |
|
|
|
use BlockScoutWeb, :router |
|
|
|
use BlockScoutWeb, :router |
|
|
|
|
|
|
|
|
|
|
|
alias BlockScoutWeb.API.RPC |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pipeline :api do |
|
|
|
pipeline :api do |
|
|
|
plug(:accepts, ["json"]) |
|
|
|
plug(:accepts, ["json"]) |
|
|
|
end |
|
|
|
end |
|
|
@ -13,12 +21,13 @@ defmodule BlockScoutWeb.ApiRouter do |
|
|
|
scope "/v1", as: :api_v1 do |
|
|
|
scope "/v1", as: :api_v1 do |
|
|
|
pipe_through(:api) |
|
|
|
pipe_through(:api) |
|
|
|
|
|
|
|
|
|
|
|
scope "/", BlockScoutWeb.API.V1 do |
|
|
|
scope "/" do |
|
|
|
get("/supply", SupplyController, :supply) |
|
|
|
alias BlockScoutWeb.API.{RPC, V1} |
|
|
|
|
|
|
|
get("/supply", V1.SupplyController, :supply) |
|
|
|
|
|
|
|
|
|
|
|
post("/eth_rpc", EthController, :eth_request) |
|
|
|
post("/eth_rpc", RPC.EthController, :eth_request) |
|
|
|
|
|
|
|
|
|
|
|
forward("/", RPCTranslator, %{ |
|
|
|
forward("/", RPC.RPCTranslator, %{ |
|
|
|
"block" => RPC.BlockController, |
|
|
|
"block" => RPC.BlockController, |
|
|
|
"account" => RPC.AddressController, |
|
|
|
"account" => RPC.AddressController, |
|
|
|
"logs" => RPC.LogsController, |
|
|
|
"logs" => RPC.LogsController, |
|
|
@ -31,12 +40,13 @@ defmodule BlockScoutWeb.ApiRouter do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
# For backward compatibility. Should be removed |
|
|
|
# For backward compatibility. Should be removed |
|
|
|
scope "/", BlockScoutWeb.API.RPC do |
|
|
|
scope "/" do |
|
|
|
|
|
|
|
alias BlockScoutWeb.API.RPC |
|
|
|
pipe_through(:api) |
|
|
|
pipe_through(:api) |
|
|
|
|
|
|
|
|
|
|
|
post("/eth_rpc", EthController, :eth_request) |
|
|
|
post("/eth_rpc", RPC.EthController, :eth_request) |
|
|
|
|
|
|
|
|
|
|
|
forward("/", RPCTranslator, %{ |
|
|
|
forward("/", RPCTranslatorForwarder, %{ |
|
|
|
"block" => RPC.BlockController, |
|
|
|
"block" => RPC.BlockController, |
|
|
|
"account" => RPC.AddressController, |
|
|
|
"account" => RPC.AddressController, |
|
|
|
"logs" => RPC.LogsController, |
|
|
|
"logs" => RPC.LogsController, |
|
|
|