debian-forge-composer/internal/client/weldr.go
Brian C. Lane 9dafb3337b Refactor error handling in the client code
client errors are now returned as an 'error', API errors as APIResponse.
2020-03-03 12:21:40 +01:00

20 lines
560 B
Go

// Package client - weldr contains functions to return API structures
// Copyright (C) 2020 by Red Hat, Inc.
package client
import (
"encoding/json"
)
// GetStatusV0 makes a GET request to /api/status and returns the v0 response as a StatusResponseV0
func GetStatusV0(socket string) (reply StatusV0, resp *APIResponse, err error) {
body, resp, err := GetRaw(socket, "GET", "/api/status")
if resp != nil || err != nil {
return reply, resp, err
}
err = json.Unmarshal(body, &reply)
if err != nil {
return reply, nil, err
}
return reply, nil, nil
}