added node syncing endpoint
This commit is contained in:
parent
7d36d953f2
commit
37bbde837b
@ -48,7 +48,8 @@ func startRESTServer(cdc *wire.Codec) func(cmd *cobra.Command, args []string) er
|
||||
func initRouter(cdc *wire.Codec) http.Handler {
|
||||
r := mux.NewRouter()
|
||||
r.HandleFunc("/version", version.VersionRequestHandler).Methods("GET")
|
||||
r.HandleFunc("/node_info", rpc.NodeStatusRequestHandler).Methods("GET")
|
||||
r.HandleFunc("/node_info", rpc.NodeInfoRequestHandler).Methods("GET")
|
||||
r.HandleFunc("/syncing", rpc.NodeSyncingRequestHandler).Methods("GET")
|
||||
r.HandleFunc("/keys", keys.QueryKeysRequestHandler).Methods("GET")
|
||||
r.HandleFunc("/keys", keys.AddNewKeyRequestHandler).Methods("POST")
|
||||
r.HandleFunc("/keys/seed", keys.SeedRequestHandler).Methods("GET")
|
||||
|
||||
@ -4,6 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
wire "github.com/tendermint/go-wire"
|
||||
@ -51,8 +52,7 @@ func printNodeStatus(cmd *cobra.Command, args []string) error {
|
||||
|
||||
// REST
|
||||
|
||||
// TODO match desired spec output
|
||||
func NodeStatusRequestHandler(w http.ResponseWriter, r *http.Request) {
|
||||
func NodeInfoRequestHandler(w http.ResponseWriter, r *http.Request) {
|
||||
status, err := getNodeStatus()
|
||||
if err != nil {
|
||||
w.WriteHeader(500)
|
||||
@ -69,3 +69,20 @@ func NodeStatusRequestHandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
w.Write(output)
|
||||
}
|
||||
|
||||
func NodeSyncingRequestHandler(w http.ResponseWriter, r *http.Request) {
|
||||
status, err := getNodeStatus()
|
||||
if err != nil {
|
||||
w.WriteHeader(500)
|
||||
w.Write([]byte(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
syncing := status.Syncing
|
||||
if err != nil {
|
||||
w.WriteHeader(500)
|
||||
w.Write([]byte(err.Error()))
|
||||
return
|
||||
}
|
||||
w.Write([]byte(strconv.FormatBool(syncing)))
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user