WithEnterpriseURLs returns a ClientOptionsFunc that sets the base and upload URLs for a Client.
(baseURL, uploadURL string)
| 468 | // WithEnterpriseURLs returns a ClientOptionsFunc that sets the base and upload |
| 469 | // URLs for a Client. |
| 470 | func WithEnterpriseURLs(baseURL, uploadURL string) ClientOptionsFunc { |
| 471 | return func(o *clientOptions) error { |
| 472 | b, err := parseURL(baseURL) |
| 473 | if err != nil { |
| 474 | return fmt.Errorf("invalid base url: %w", err) |
| 475 | } |
| 476 | |
| 477 | if !strings.HasSuffix(b.Path, "/api/v3/") && |
| 478 | !strings.HasPrefix(b.Host, "api.") && |
| 479 | !strings.Contains(b.Host, ".api.") { |
| 480 | b.Path += "api/v3/" |
| 481 | } |
| 482 | |
| 483 | o.baseURL = b |
| 484 | |
| 485 | u, err := parseURL(uploadURL) |
| 486 | if err != nil { |
| 487 | return fmt.Errorf("invalid upload url: %w", err) |
| 488 | } |
| 489 | |
| 490 | if !strings.HasSuffix(u.Path, "/api/uploads/") && |
| 491 | !strings.HasPrefix(u.Host, "api.") && |
| 492 | !strings.Contains(u.Host, ".api.") && |
| 493 | !strings.HasPrefix(u.Host, "uploads.") { |
| 494 | u.Path += "api/uploads/" |
| 495 | } |
| 496 | |
| 497 | o.uploadURL = u |
| 498 | |
| 499 | return nil |
| 500 | } |
| 501 | } |
| 502 | |
| 503 | // WithDisableRateLimitCheck returns a ClientOptionsFunc that disables rate |
| 504 | // limit checking for a Client. If not set, the client will check for rate |
searching dependent graphs…