53 lines
838 B
Go
53 lines
838 B
Go
package server
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/rs/zerolog/log"
|
|
|
|
"git.grassecon.org/grassroots-economics/openethereum-node-status/pkg/rpc"
|
|
)
|
|
|
|
type (
|
|
R struct {
|
|
Result string `json:"result"`
|
|
}
|
|
|
|
P map[string]interface{}
|
|
)
|
|
|
|
var (
|
|
RpcClient rpc.RpcClient
|
|
)
|
|
|
|
func metricsHandler(c *gin.Context) {
|
|
// pllholder rpc call
|
|
rpcResponse, err := RpcClient.EthRpcCall("eth_gasPrice")
|
|
if err != nil {
|
|
log.Error().
|
|
Err(err).
|
|
Str("module", "server").
|
|
Msg("rpc call failed")
|
|
}
|
|
|
|
value, err := rpcResponse.GetString()
|
|
if err != nil {
|
|
log.Error().
|
|
Err(err).
|
|
Str("module", "server").
|
|
Msg("rpc response to string conversion failed")
|
|
}
|
|
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"ok": true,
|
|
"data": value,
|
|
})
|
|
}
|
|
|
|
func healthHandler(c *gin.Context) {
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"ok": true,
|
|
})
|
|
}
|