add version info endpoint to gateway
Jeromy committed
Feb 20, 2015 at 11:49 UTC
69e09d40c56570f9eaad8692c0d125c60d598b18
3 files changed
+14
-1
cmd/ipfs/daemon.go
+1
@@ -208,6 +208,7 @@ func daemonFunc(req cmds.Request, res cmds.Response) {
208
if gatewayMaddr != nil {
209
go func() {
210
var opts = []corehttp.ServeOption{
211
+ corehttp.VersionOption(),
212
corehttp.IPNSHostnameOption(),
213
corehttp.GatewayOption(writable),
214
}
core/corehttp/gateway.go
+12
@@ -1,10 +1,12 @@
1
package corehttp
2
3
import (
4
+ "fmt"
5
"net/http"
6
"sync"
7
8
core "github.com/jbenet/go-ipfs/core"
9
+ id "github.com/jbenet/go-ipfs/p2p/protocol/identify"
10
)
11
12
// Gateway should be instantiated using NewGateway
@@ -43,6 +45,16 @@ func GatewayOption(writable bool) ServeOption {
45
return g.ServeOption()
46
}
47
48
+func VersionOption() ServeOption {
49
+ return func(n *core.IpfsNode, mux *http.ServeMux) (*http.ServeMux, error) {
50
+ mux.HandleFunc("/version", func(w http.ResponseWriter, r *http.Request) {
51
+ fmt.Fprintf(w, "Client Version: %s\n", id.ClientVersion)
52
+ fmt.Fprintf(w, "Protocol Version: %s\n", id.IpfsVersion)
53
+ })
54
+ return mux, nil
55
+ }
56
+}
57
+
58
// Decider decides whether to Allow string
59
type Decider func(string) bool
60
repo/config/version.go
+1
-1
@@ -8,7 +8,7 @@ import (
8
)
9
10
// CurrentVersionNumber is the current application's version literal
11
-const CurrentVersionNumber = "0.1.7"
11
+const CurrentVersionNumber = "0.2.0"
12
13
// Version regulates checking if the most recent version is run
14
type Version struct {