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