d23512e9c6
Co-authored-by: AlteredCoder <AlteredCoder>
25 lines
548 B
Go
25 lines
548 B
Go
package cwapi
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
)
|
|
|
|
func (ctx *ApiCtx) PullTop() ([]map[string]string, error) {
|
|
top := &PullResp{}
|
|
errResp := &ApiResp{}
|
|
|
|
resp, err := ctx.Http.New().Get(ctx.PullPath).Receive(top, errResp)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("api pull: HTTP request creation failed: %s", err)
|
|
}
|
|
|
|
if resp.StatusCode != 200 {
|
|
return nil, fmt.Errorf("api pull: return bad HTTP code (%d): %s", resp.StatusCode, errResp.Message)
|
|
}
|
|
|
|
log.Debugf("api pull: response : %+v", top.Body)
|
|
return top.Body, nil
|
|
}
|