Allow full config via environment
This commit is contained in:
parent
117d04912f
commit
112cd5874b
@ -23,15 +23,22 @@ func NewClient(options ...func(*Client)) *Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// set defaults
|
// set defaults
|
||||||
|
var ok bool
|
||||||
if c.BaseUrl == "" {
|
if c.BaseUrl == "" {
|
||||||
|
c.BaseUrl, ok = os.LookupEnv("SN_BASE_URL")
|
||||||
|
if !ok {
|
||||||
c.BaseUrl = "https://stacker.news"
|
c.BaseUrl = "https://stacker.news"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if c.ApiKey == "" {
|
if c.ApiKey == "" {
|
||||||
c.ApiKey = os.Getenv("SN_API_KEY")
|
c.ApiKey = os.Getenv("SN_API_KEY")
|
||||||
}
|
}
|
||||||
if c.MediaUrl == "" {
|
if c.MediaUrl == "" {
|
||||||
|
c.MediaUrl, ok = os.LookupEnv("SN_MEDIA_URL")
|
||||||
|
if !ok {
|
||||||
c.MediaUrl = "https://m.stacker.news"
|
c.MediaUrl = "https://m.stacker.news"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
c.ApiUrl = fmt.Sprintf("%s/api/graphql", c.BaseUrl)
|
c.ApiUrl = fmt.Sprintf("%s/api/graphql", c.BaseUrl)
|
||||||
|
|
||||||
return c
|
return c
|
||||||
|
Loading…
x
Reference in New Issue
Block a user