mirror of
https://github.com/ipfs/kubo.git
synced 2025-09-10 05:52:20 +08:00
add version info endpoint to gateway
This commit is contained in:
@ -208,6 +208,7 @@ func daemonFunc(req cmds.Request, res cmds.Response) {
|
||||
if gatewayMaddr != nil {
|
||||
go func() {
|
||||
var opts = []corehttp.ServeOption{
|
||||
corehttp.VersionOption(),
|
||||
corehttp.IPNSHostnameOption(),
|
||||
corehttp.GatewayOption(writable),
|
||||
}
|
||||
|
@ -1,10 +1,12 @@
|
||||
package corehttp
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"sync"
|
||||
|
||||
core "github.com/jbenet/go-ipfs/core"
|
||||
id "github.com/jbenet/go-ipfs/p2p/protocol/identify"
|
||||
)
|
||||
|
||||
// Gateway should be instantiated using NewGateway
|
||||
@ -43,6 +45,16 @@ func GatewayOption(writable bool) ServeOption {
|
||||
return g.ServeOption()
|
||||
}
|
||||
|
||||
func VersionOption() ServeOption {
|
||||
return func(n *core.IpfsNode, mux *http.ServeMux) (*http.ServeMux, error) {
|
||||
mux.HandleFunc("/version", func(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprintf(w, "Client Version: %s\n", id.ClientVersion)
|
||||
fmt.Fprintf(w, "Protocol Version: %s\n", id.IpfsVersion)
|
||||
})
|
||||
return mux, nil
|
||||
}
|
||||
}
|
||||
|
||||
// Decider decides whether to Allow string
|
||||
type Decider func(string) bool
|
||||
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
)
|
||||
|
||||
// CurrentVersionNumber is the current application's version literal
|
||||
const CurrentVersionNumber = "0.1.7"
|
||||
const CurrentVersionNumber = "0.2.0"
|
||||
|
||||
// Version regulates checking if the most recent version is run
|
||||
type Version struct {
|
||||
|
Reference in New Issue
Block a user