1
0
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:
Jeromy
2015-02-20 11:49:48 -08:00
parent 080c0de9af
commit 69e09d40c5
3 changed files with 14 additions and 1 deletions

View File

@ -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),
}

View File

@ -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

View File

@ -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 {