31 lines
522 B
Go
31 lines
522 B
Go
package hydra
|
|
|
|
import (
|
|
"net/url"
|
|
"time"
|
|
|
|
"github.com/pkg/errors"
|
|
"gitlab.com/wpetit/goweb/service"
|
|
)
|
|
|
|
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")
|
|
}
|
|
|
|
client := NewClient(baseURL, httpTimeout)
|
|
|
|
return func(ctn *service.Container) (interface{}, error) {
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return client, nil
|
|
}
|
|
}
|