crowdsec/pkg/cwapi/pull.go
AlteredCoder 55d5b6842c fix
2020-07-27 18:35:31 +02:00

23 lines
495 B
Go

package cwapi
import (
"fmt"
log "github.com/sirupsen/logrus"
)
func (ctx *ApiCtx) PullTop() ([]map[string]string, error) {
top := &PullResp{}
resp, err := ctx.Http.Get(ctx.PullPath).ReceiveSuccess(top)
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)", resp.StatusCode)
}
log.Debugf("api pull: response : %+v", top.Body)
return top.Body, nil
}