Add more options to NewConfiguration using functional options.

This commit is contained in:
Nikos Katirtzis 2018-08-06 22:41:10 +01:00
parent a65c6ca5d4
commit 0d7bd0b4df

View File

@ -55,12 +55,17 @@ type Configuration struct {
} }
// NewConfiguration create new configuration // NewConfiguration create new configuration
func NewConfiguration(basePath string) *Configuration { func NewConfiguration(basePath string, options ...func(*Configuration)) *Configuration {
cfg := &Configuration{ cfg := &Configuration{
BasePath: basePath, BasePath: basePath,
DefaultHeader: make(map[string]string), DefaultHeader: make(map[string]string),
UserAgent: "go-bitbucket/1.0.0/go", UserAgent: "go-bitbucket/1.0.0/go",
} }
for _, option := range options {
option(cfg)
}
return cfg return cfg
} }