Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ import (
// Client is containing the configured http.Client
// and the host url
type HttpBasicAuth struct {
User string
Pass string
User string
Pass string
}

type Client struct {
Url string
Url string
HTTPClient *http.Client
Auth *HttpBasicAuth
Auth *HttpBasicAuth
}

type UpdateResp struct {
Expand All @@ -44,9 +44,9 @@ func NewClient(host string, auth *HttpBasicAuth, tlsConfig *tls.Config) (*Client
}

return &Client{
Url: h.String(),
Url: h.String(),
HTTPClient: newHTTPClient(h, tlsConfig),
Auth: auth,
Auth: auth,
}, nil
}

Expand All @@ -63,7 +63,7 @@ func (c *Client) do(method, path string, data interface{}) ([]byte, int, error)
params = bytes.NewBuffer(buf)
}

req, err := http.NewRequest(method, c.Url + path, params)
req, err := http.NewRequest(method, c.Url+path, params)
if err != nil {
return nil, -1, err
}
Expand All @@ -72,9 +72,9 @@ func (c *Client) do(method, path string, data interface{}) ([]byte, int, error)
req.Header.Set("User-Agent", "gomarathon")
req.Header.Set("Content-Type", "application/json")

if c.Auth != nil {
req.SetBasicAuth(c.Auth.User, c.Auth.Pass)
}
if c.Auth != nil {
req.SetBasicAuth(c.Auth.User, c.Auth.Pass)
}

resp, err = c.HTTPClient.Do(req)
if err != nil {
Expand Down Expand Up @@ -113,19 +113,19 @@ func (c *Client) request(options *RequestOptions) (*Response, error) {
v := url.Values{}

if options.Params.Cmd != "" {
v.Set("cmd", url.QueryEscape(options.Params.Cmd))
v.Set("cmd", options.Params.Cmd)
}

if options.Params.Host != "" {
v.Set("host", url.QueryEscape(options.Params.Host))
v.Set("host", options.Params.Host)
}

if options.Params.Scale {
v.Set("scale", "true")
}

if options.Params.CallbackURL != "" {
v.Set("CallbackURL", url.QueryEscape(options.Params.CallbackURL))
v.Set("CallbackURL", options.Params.CallbackURL)
}

path = fmt.Sprintf("%s?%s", path, v.Encode())
Expand Down
5 changes: 2 additions & 3 deletions subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package gomarathon

import (
"fmt"
"net/url"
)

// RegisterCallbackURL register a new callback url
Expand All @@ -11,7 +10,7 @@ func (c *Client) RegisterCallbackURL(uri string) (*Response, error) {
Path: "eventSubscriptions",
Method: "POST",
Params: &Parameters{
CallbackURL: url.QueryEscape(uri),
CallbackURL: uri,
},
}
r, err := c.request(options)
Expand Down Expand Up @@ -44,7 +43,7 @@ func (c *Client) DeleteCallbackURL(uri string) (*Response, error) {
Path: "eventSubscriptions",
Method: "DELETE",
Params: &Parameters{
CallbackURL: url.QueryEscape(uri),
CallbackURL: uri,
},
}
r, err := c.request(options)
Expand Down