Skip to content

Commit 5e561e3

Browse files
authored
fix cwapi bug with new sling usage (#157)
* fix sling usage Co-authored-by: AlteredCoder <AlteredCoder>
1 parent 89c8d1a commit 5e561e3

3 files changed

Lines changed: 6 additions & 5 deletions

File tree

pkg/cwapi/auth.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ func (ctx *ApiCtx) Signin() error {
142142
}
143143
jsonResp := &ApiResp{}
144144

145-
resp, err := ctx.Http.Post(ctx.SigninPath).BodyJSON(ctx.Creds).ReceiveSuccess(jsonResp)
145+
resp, err := ctx.Http.New().Post(ctx.SigninPath).BodyJSON(ctx.Creds).ReceiveSuccess(jsonResp)
146146
if err != nil {
147147
return fmt.Errorf("api signin: HTTP request creation failed: %s", err)
148148
}
@@ -155,6 +155,7 @@ func (ctx *ApiCtx) Signin() error {
155155
}
156156

157157
ctx.Http = ctx.Http.Set("Authorization", jsonResp.Message)
158+
158159
log.Printf("api signin: signed in successfuly")
159160
return nil
160161
}
@@ -164,7 +165,7 @@ func (ctx *ApiCtx) RegisterMachine(machineID string, password string) error {
164165
ctx.Creds.Password = password
165166
jsonResp := &ApiResp{}
166167

167-
resp, err := ctx.Http.Post(ctx.RegisterPath).BodyJSON(ctx.Creds).ReceiveSuccess(jsonResp)
168+
resp, err := ctx.Http.New().Post(ctx.RegisterPath).BodyJSON(ctx.Creds).ReceiveSuccess(jsonResp)
168169
if err != nil {
169170
return fmt.Errorf("api register machine: HTTP request creation failed: %s", err)
170171
}
@@ -185,7 +186,7 @@ func (ctx *ApiCtx) ResetPassword(machineID string, password string) error {
185186
jsonResp := &ApiResp{}
186187

187188
data := map[string]string{"machine_id": ctx.Creds.User, "password": ctx.Creds.Password}
188-
resp, err := ctx.Http.Post(ctx.ResetPwdPath).BodyJSON(data).ReceiveSuccess(jsonResp)
189+
resp, err := ctx.Http.New().Post(ctx.ResetPwdPath).BodyJSON(data).ReceiveSuccess(jsonResp)
189190
if err != nil {
190191
return fmt.Errorf("api reset password: HTTP request creation failed: %s", err)
191192
}

pkg/cwapi/enroll.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ func (ctx *ApiCtx) Enroll(userID string) error {
1010
toPush := map[string]string{"user_id": userID}
1111
jsonResp := &ApiResp{}
1212

13-
resp, err := ctx.Http.Post(ctx.EnrollPath).BodyJSON(&toPush).ReceiveSuccess(jsonResp)
13+
resp, err := ctx.Http.New().Post(ctx.EnrollPath).BodyJSON(&toPush).ReceiveSuccess(jsonResp)
1414
if err != nil {
1515
return fmt.Errorf("api enroll: HTTP request creation failed: %s", err)
1616
}

pkg/cwapi/pull.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88

99
func (ctx *ApiCtx) PullTop() ([]map[string]string, error) {
1010
top := &PullResp{}
11-
resp, err := ctx.Http.Get(ctx.PullPath).ReceiveSuccess(top)
11+
resp, err := ctx.Http.New().Get(ctx.PullPath).ReceiveSuccess(top)
1212
if err != nil {
1313
return nil, fmt.Errorf("api pull: HTTP request creation failed: %s", err)
1414
}

0 commit comments

Comments
 (0)