worker: Make BasePath configurable

This commit is contained in:
sanne 2021-10-07 14:03:19 +02:00 committed by Ondřej Budai
parent 6ce20a9ef6
commit ce7ac9a756
11 changed files with 106 additions and 25 deletions

View file

@ -55,12 +55,14 @@ type job struct {
dynamicArgs []json.RawMessage
}
func NewClient(baseURL string, conf *tls.Config, offlineToken, oAuthURL *string) (*Client, error) {
func NewClient(baseURL string, conf *tls.Config, offlineToken, oAuthURL *string, basePath string) (*Client, error) {
server, err := url.Parse(baseURL)
if err != nil {
return nil, err
}
api.BasePath = basePath
server, err = server.Parse(api.BasePath + "/")
if err != nil {
panic(err)
@ -76,12 +78,14 @@ func NewClient(baseURL string, conf *tls.Config, offlineToken, oAuthURL *string)
return &Client{server, requester, offlineToken, oAuthURL, nil, nil, &sync.Mutex{}}, nil
}
func NewClientUnix(path string) *Client {
func NewClientUnix(path string, basePath string) *Client {
server, err := url.Parse("http://localhost/")
if err != nil {
panic(err)
}
api.BasePath = basePath
server, err = server.Parse(api.BasePath + "/")
if err != nil {
panic(err)