Skip to content

Commit

Permalink
Resolve conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
dinh-tran committed Dec 22, 2017
2 parents e008df9 + 4cf2d24 commit df9bfeb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ to access [kintone][] with its official REST API ([en][APIen], [ja][APIja]).

## Version

0.1.0
0.1.1

## License

Expand Down
19 changes: 19 additions & 0 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (
)

const (
NAME = "kintone-go-SDK"
VERSION = "0.1.1"
DEFAULT_TIMEOUT = time.Second * 600 // Default value for App.Timeout
)

Expand Down Expand Up @@ -101,6 +103,7 @@ type App struct {
basicAuth bool // true to use Basic Authentication.
basicAuthUser string // User name for Basic Authentication.
basicAuthPassword string // Password for Basic Authentication.
userAgentHeader string // User-agent request header string
}

// SetBasicAuth enables use of HTTP basic authentication for access
Expand All @@ -126,6 +129,16 @@ func (app *App) GetBasicAuthPassword() string {
return app.basicAuthPassword
}

// SetUserAgentHeader set custom user-agent header for http request
func (app *App) SetUserAgentHeader(userAgentHeader string) {
app.userAgentHeader = userAgentHeader
}

// GetUserAgentHeader get user-agent header string
func (app *App) GetUserAgentHeader() string {
return app.userAgentHeader
}

func (app *App) newRequest(method, api string, body io.Reader) (*http.Request, error) {
if len(app.token) == 0 {
app.token = base64.StdEncoding.EncodeToString(
Expand Down Expand Up @@ -157,6 +170,12 @@ func (app *App) newRequest(method, api string, body io.Reader) (*http.Request, e
req.Header.Set("X-Cybozu-API-Token", app.ApiToken)
}
req.Header.Set("Content-Type", "application/json")

if len(app.GetUserAgentHeader()) != 0 {
req.Header.Set("User-Agent", app.userAgentHeader)
} else {
req.Header.Set("User-Agent", NAME+"/"+VERSION)
}
return req, nil
}

Expand Down

0 comments on commit df9bfeb

Please sign in to comment.