mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-11-13 03:25:20 +00:00
33 lines
783 B
Go
33 lines
783 B
Go
|
// Copyright 2016 All in Bits, inc
|
||
|
// Modifications copyright 2018 Kava Labs
|
||
|
|
||
|
package lcd
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"net/http"
|
||
|
|
||
|
"github.com/cosmos/cosmos-sdk/client/context"
|
||
|
"github.com/cosmos/cosmos-sdk/version"
|
||
|
)
|
||
|
|
||
|
// cli version REST handler endpoint
|
||
|
func CLIVersionRequestHandler(w http.ResponseWriter, r *http.Request) {
|
||
|
v := version.GetVersion()
|
||
|
w.Write([]byte(v))
|
||
|
}
|
||
|
|
||
|
// connected node version REST handler endpoint
|
||
|
func NodeVersionRequestHandler(cliCtx context.CLIContext) http.HandlerFunc {
|
||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||
|
version, err := cliCtx.Query("/app/version")
|
||
|
if err != nil {
|
||
|
w.WriteHeader(http.StatusInternalServerError)
|
||
|
w.Write([]byte(fmt.Sprintf("Could't query version. Error: %s", err.Error())))
|
||
|
return
|
||
|
}
|
||
|
|
||
|
w.Write(version)
|
||
|
}
|
||
|
}
|