Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions internal/apiclient.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package internal

import "os"

// APIClient is a minimal client for the (future) demo API.
type APIClient struct {
APIKey string
}

// NewAPIClientFromEnv builds a client using the API key from the
// DEMO_API_KEY environment variable. Returns an error if it's unset.
func NewAPIClientFromEnv() (*APIClient, error) {
key := os.Getenv("DEMO_API_KEY")
if key == "" {
return nil, errMissingAPIKey
}
return &APIClient{APIKey: key}, nil
}
5 changes: 5 additions & 0 deletions internal/errors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package internal

import "errors"

var errMissingAPIKey = errors.New("DEMO_API_KEY environment variable is not set")
Loading