hydra-passwordless/internal/hydra/provider.go

31 lines
567 B
Go
Raw Normal View History

2020-04-08 08:56:42 +02:00
package hydra
import (
2020-04-24 09:27:07 +02:00
"net/url"
2020-04-08 08:56:42 +02:00
"time"
2020-04-24 09:27:07 +02:00
"github.com/pkg/errors"
2020-04-08 08:56:42 +02:00
"gitlab.com/wpetit/goweb/service"
)
func ServiceProvider(rawBaseURL string, fakeSSLTermination bool, httpTimeout time.Duration) service.Provider {
2020-04-24 09:27:07 +02:00
var (
baseURL *url.URL
err error
)
baseURL, err = url.Parse(rawBaseURL)
if err != nil {
err = errors.Wrap(err, "could not parse base url")
}
client := NewClient(baseURL, fakeSSLTermination, httpTimeout)
2020-04-08 08:56:42 +02:00
return func(ctn *service.Container) (interface{}, error) {
2020-04-24 09:27:07 +02:00
if err != nil {
return nil, err
}
2020-04-08 08:56:42 +02:00
return client, nil
}
}