WithURLs returns a ClientOptionsFunc that sets the base and upload URLs while only validating the URL format. Nil values will be ignored and default URLs will be used.
(baseURL, uploadURL *string)
| 442 | // while only validating the URL format. Nil values will be ignored and default |
| 443 | // URLs will be used. |
| 444 | func WithURLs(baseURL, uploadURL *string) ClientOptionsFunc { |
| 445 | return func(o *clientOptions) error { |
| 446 | if baseURL != nil { |
| 447 | b, err := parseURL(*baseURL) |
| 448 | if err != nil { |
| 449 | return fmt.Errorf("invalid base url: %w", err) |
| 450 | } |
| 451 | |
| 452 | o.baseURL = b |
| 453 | } |
| 454 | |
| 455 | if uploadURL != nil { |
| 456 | u, err := parseURL(*uploadURL) |
| 457 | if err != nil { |
| 458 | return fmt.Errorf("invalid upload url: %w", err) |
| 459 | } |
| 460 | |
| 461 | o.uploadURL = u |
| 462 | } |
| 463 | |
| 464 | return nil |
| 465 | } |
| 466 | } |
| 467 | |
| 468 | // WithEnterpriseURLs returns a ClientOptionsFunc that sets the base and upload |
| 469 | // URLs for a Client. |
searching dependent graphs…