瀏覽代碼

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

tags/v1^0
Matt Baer 5 年之前
父節點
當前提交
e897d3699f
沒有發現已知的金鑰在資料庫的簽署中 GPG 金鑰 ID: 9C4CE3A27D62A6FB
共有 1 個檔案被更改,包括 8 行新增1 行删除
  1. +8
    -1
      writeas.go

+ 8
- 1
writeas.go 查看文件

@@ -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…
取消
儲存