From 4df55f0d68f7098729d324b0ee5ff9e3124c1538 Mon Sep 17 00:00:00 2001 From: poliha Date: Thu, 2 May 2019 21:04:38 +0100 Subject: [PATCH] horizonclient: add version (#1229) * add package version * fix go fmt --- clients/horizonclient/client.go | 9 ++++++--- clients/horizonclient/version.go | 5 +++++ 2 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 clients/horizonclient/version.go diff --git a/clients/horizonclient/client.go b/clients/horizonclient/client.go index 1f88e36c1f..a354940caf 100644 --- a/clients/horizonclient/client.go +++ b/clients/horizonclient/client.go @@ -17,7 +17,6 @@ import ( "github.com/manucorporat/sse" hProtocol "github.com/stellar/go/protocols/horizon" "github.com/stellar/go/protocols/horizon/operations" - "github.com/stellar/go/support/app" "github.com/stellar/go/support/errors" ) @@ -94,7 +93,6 @@ func (c *Client) stream( } req.Header.Set("Accept", "text/event-stream") c.setDefaultClient() - // to do: confirm name and version c.setClientAppHeaders(req) // We can use c.HTTP here because we set Timeout per request not on the client. See sendRequest() @@ -199,7 +197,7 @@ func (c *Client) stream( func (c *Client) setClientAppHeaders(req *http.Request) { req.Header.Set("X-Client-Name", "go-stellar-sdk") - req.Header.Set("X-Client-Version", app.Version()) + req.Header.Set("X-Client-Version", c.Version()) req.Header.Set("X-App-Name", c.AppName) req.Header.Set("X-App-Version", c.AppVersion) } @@ -523,5 +521,10 @@ func (c *Client) Root() (root hProtocol.Root, err error) { return } +// Version returns the current version. +func (c *Client) Version() string { + return version +} + // ensure that the horizon client implements ClientInterface var _ ClientInterface = &Client{} diff --git a/clients/horizonclient/version.go b/clients/horizonclient/version.go new file mode 100644 index 0000000000..862c1174d3 --- /dev/null +++ b/clients/horizonclient/version.go @@ -0,0 +1,5 @@ +package horizonclient + +// version is the current version of the horizonclient. +// This is updated for every release. +const version = "1.1"