diff --git a/transport.go b/transport.go index b14635b..258be39 100644 --- a/transport.go +++ b/transport.go @@ -11,6 +11,12 @@ type Transport struct { APIKey string } +// NewTransport constructs and returns a new Transport struct that includes the +// given API key as a header in each request. +func NewTransport(apiKey string) *Transport { + return &Transport{APIKey: apiKey} +} + // Client returns an HTTP client that will include the API key in the request, // and is safe for concurrent use by multiple goroutines. func (t *Transport) Client() *http.Client { diff --git a/transport_test.go b/transport_test.go index cdf3a1b..9c26d27 100644 --- a/transport_test.go +++ b/transport_test.go @@ -1 +1,11 @@ package anthropic + +import "testing" + +func TestNewTransport(t *testing.T) { + apiKey := "test-api-key" + transport := NewTransport(apiKey) + if transport.APIKey != apiKey { + t.Errorf("transport.APIKey = %q, want %q", transport.APIKey, apiKey) + } +}