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-05-21 13:12:17 +02:00
|
|
|
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")
|
|
|
|
}
|
|
|
|
|
2020-05-21 13:12:17 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|