Browse Source

Version 1, with basic API support around publishing, updating, and deleting posts.

tags/v1^0
Matt Baer 5 years ago
parent
commit
e897d3699f
No known key found for this signature in database GPG Key ID: 9C4CE3A27D62A6FB
1 changed files with 8 additions and 1 deletions
  1. +8
    -1
      writeas.go

+ 8
- 1
writeas.go View File

@@ -27,6 +27,9 @@ type Client struct {
token string
// Client making requests to the API
client *http.Client

// UserAgent overrides the default User-Agent header
UserAgent string
}

// defaultHTTPTimeout is the default http.Client timeout.
@@ -151,7 +154,11 @@ func (c *Client) doRequest(r *http.Request, result interface{}) (*impart.Envelop
}

func (c *Client) prepareRequest(r *http.Request) {
r.Header.Add("User-Agent", "go-writeas v1")
ua := c.UserAgent
if ua == "" {
ua = "go-writeas v1"
}
r.Header.Add("User-Agent", ua)
r.Header.Add("Content-Type", "application/json")
if c.token != "" {
r.Header.Add("Authorization", "Token "+c.token)


Loading…
Cancel
Save