package supplier import ( "fmt" "net/url" "github.com/go-resty/resty/v2" ) type ServiceProviderOptions struct { Version string Name string } func NewServiceProviderSupplier(name string, u *url.URL, opts ServiceProviderOptions) (ServiceProviderSupplier, error) { if err := validateUrl(u); err != nil { return nil, err } pass, _ := u.User.Password() user := u.User.Username() u.User = nil config := spConfig{ Host: u.String(), Username: user, Password: pass, Name: opts.Name, Version: opts.Version, } switch name { case "rocketchat": return &rocketchat{ // until the app is added to the marketplace. sideLoading: true, spConfig: config, Client: resty.New(). SetBaseURL(config.Host). SetHeader("Content-Type", "application/json"), }, nil } return nil, fmt.Errorf("unkown service provider : %s", name) }