github.com/clerkinc/clerk-sdk-go@v1.49.1/clerk/clerk_options.go (about)

     1  package clerk
     2  
     3  import (
     4  	"errors"
     5  	"net/http"
     6  )
     7  
     8  // ClerkOption describes a functional parameter for the clerk client constructor
     9  type ClerkOption func(*client) error
    10  
    11  // WithHTTPClient allows the overriding of the http client
    12  func WithHTTPClient(httpClient *http.Client) ClerkOption {
    13  	return func(c *client) error {
    14  		if httpClient == nil {
    15  			return errors.New("http client can't be nil")
    16  		}
    17  
    18  		c.client = httpClient
    19  		return nil
    20  	}
    21  }
    22  
    23  // WithBaseURL allows the overriding of the base URL
    24  func WithBaseURL(rawURL string) ClerkOption {
    25  	return func(c *client) error {
    26  		if rawURL == "" {
    27  			return errors.New("base url can't be empty")
    28  		}
    29  
    30  		baseURL, err := toURLWithEndingSlash(rawURL)
    31  		if err != nil {
    32  			return err
    33  		}
    34  
    35  		c.baseURL = baseURL
    36  		return nil
    37  	}
    38  }