Read API key from environment
This commit is contained in:
parent
5ba3c56b75
commit
ffc5baa79c
|
@ -6,6 +6,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ClientOptions struct {
|
type ClientOptions struct {
|
||||||
|
@ -23,6 +24,9 @@ func NewClient(options *ClientOptions) *Client {
|
||||||
if options.BaseUrl == "" {
|
if options.BaseUrl == "" {
|
||||||
options.BaseUrl = "https://stacker.news"
|
options.BaseUrl = "https://stacker.news"
|
||||||
}
|
}
|
||||||
|
if options.ApiKey == "" {
|
||||||
|
options.ApiKey = os.Getenv("SN_API_KEY")
|
||||||
|
}
|
||||||
|
|
||||||
return &Client{
|
return &Client{
|
||||||
BaseUrl: options.BaseUrl,
|
BaseUrl: options.BaseUrl,
|
||||||
|
|
Loading…
Reference in New Issue