Commit 064e0c6d authored by Corentin Barreau's avatar Corentin Barreau
Browse files

Merge branch 'project-identification' into 'master'

feat: add X-Identifier to /feed requests so that they are resetable

See merge request !2
parents 97c9ffd4 53d83b2d
......@@ -25,6 +25,11 @@ func (c *Client) Feed(size int) (feedResponse *FeedResponse, err error) {
req.Header.Add("X-Auth-Key", c.Key)
req.Header.Add("X-Auth-Secret", c.Secret)
if c.Identifier != "" {
req.Header.Add("X-Identifier", c.Identifier)
}
req.Header.Add("User-Agent", "gocrawlhq/"+Version)
// execute request
......
......@@ -3,6 +3,7 @@ package gocrawlhq
import (
"net/http"
"net/url"
"os"
"path"
)
......@@ -11,7 +12,7 @@ var (
FinishedEndpoint *url.URL
FeedEndpoint *url.URL
Version = "1.1.3"
Version = "1.1.4"
)
func Init(key, secret, project, HQAddress string) (c *Client, err error) {
......@@ -23,6 +24,13 @@ func Init(key, secret, project, HQAddress string) (c *Client, err error) {
c.HTTPClient = http.DefaultClient
c.HQAddress = HQAddress
hostname, err := os.Hostname()
if err != nil {
return c, err
}
c.Identifier = hostname + "-" + project
DiscoveredEndpoint, err = url.Parse(c.HQAddress)
if err != nil {
return c, err
......
......@@ -7,6 +7,7 @@ type Client struct {
Secret string
Project string
HQAddress string
Identifier string
HTTPClient *http.Client
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment