hydra-passwordless/internal/hydra/provider.go

31 lines
522 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"
)
2020-04-24 09:27:07 +02:00
func ServiceProvider(rawBaseURL string, httpTimeout time.Duration) service.Provider {
var (
baseURL *url.URL
err error
)
baseURL, err = url.Parse(rawBaseURL)
if err != nil {
err = errors.Wrap(err, "could not parse base url")
}
2020-04-08 08:56:42 +02:00
client := NewClient(baseURL, httpTimeout)
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
}
}