options.go 719 B

123456789101112131415161718192021222324252627282930
  1. // SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
  2. // SPDX-License-Identifier: Apache-2.0
  3. package client // import "miniflux.app/v2/client"
  4. import "net/http"
  5. type Option func(*request)
  6. // WithAPIKey sets the API key for the client.
  7. func WithAPIKey(apiKey string) Option {
  8. return func(r *request) {
  9. r.apiKey = apiKey
  10. }
  11. }
  12. // WithCredentials sets the username and password for the client.
  13. func WithCredentials(username, password string) Option {
  14. return func(r *request) {
  15. r.username = username
  16. r.password = password
  17. }
  18. }
  19. // WithHTTPClient sets the HTTP client for the client.
  20. func WithHTTPClient(client *http.Client) Option {
  21. return func(r *request) {
  22. r.client = client
  23. }
  24. }