Skip to content

Commit

Permalink
Use HTTP storage if none is given in NewHTTPClient (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
MicahParks authored Dec 13, 2023
1 parent 723e340 commit b7c3a1f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion http.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,14 @@ func NewHTTPClient(options HTTPClientOptions) (Storage, error) {
}
for u, store := range options.HTTPURLs {
if store == nil {
options.HTTPURLs[u] = NewMemoryStorage()
parsed, err := url.ParseRequestURI(u)
if err != nil {
return nil, fmt.Errorf("failed to parse given URL %q: %w", u, errors.Join(err, ErrNewClient))
}
options.HTTPURLs[u], err = NewStorageFromHTTP(nil, HTTPClientStorageOptions{})
if err != nil {
return nil, fmt.Errorf("failed to create HTTP client storage for %q: %w", parsed.String(), errors.Join(err, ErrNewClient))
}
}
}
given := options.Given
Expand Down

0 comments on commit b7c3a1f

Please sign in to comment.