From aabf80723d5d635695ea183c4ffe67d712cd51ae Mon Sep 17 00:00:00 2001 From: rht Date: Wed, 16 Dec 2015 10:50:37 +0700 Subject: [PATCH] Move api version string to repo config License: MIT Signed-off-by: rht --- commands/http/client.go | 3 +-- commands/http/handler.go | 2 +- repo/config/version.go | 2 ++ 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/commands/http/client.go b/commands/http/client.go index 3da268ffee9..9383e1f5d68 100644 --- a/commands/http/client.go +++ b/commands/http/client.go @@ -100,8 +100,7 @@ func (c *client) Send(req cmds.Request) (cmds.Response, error) { } else { httpReq.Header.Set(contentTypeHeader, applicationOctetStream) } - version := config.CurrentVersionNumber - httpReq.Header.Set(uaHeader, fmt.Sprintf("/go-ipfs/%s/", version)) + httpReq.Header.Set(uaHeader, config.ApiVersion) ec := make(chan error, 1) rc := make(chan cmds.Response, 1) diff --git a/commands/http/handler.go b/commands/http/handler.go index df590e18c08..6dd38616304 100644 --- a/commands/http/handler.go +++ b/commands/http/handler.go @@ -439,7 +439,7 @@ func apiVersionMatches(r *http.Request) error { return nil } - daemonVersion := fmt.Sprintf("/go-ipfs/%s/", config.CurrentVersionNumber) + daemonVersion := config.ApiVersion if daemonVersion != clientVersion { return fmt.Errorf("%s (%s != %s)", errApiVersionMismatch, daemonVersion, clientVersion) } diff --git a/repo/config/version.go b/repo/config/version.go index e672ac08ce7..d11b9d518bb 100644 --- a/repo/config/version.go +++ b/repo/config/version.go @@ -10,6 +10,8 @@ import ( // CurrentVersionNumber is the current application's version literal const CurrentVersionNumber = "0.3.11-dev" +const ApiVersion = "/go-ipfs/" + CurrentVersionNumber + "/" + // CurrentCommit is the current git commit, this is set as a ldflag in the Makefile var CurrentCommit string