-
Notifications
You must be signed in to change notification settings - Fork 6
/
detailedreport.go
44 lines (36 loc) · 938 Bytes
/
detailedreport.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package vcodeapi
import (
"errors"
"io/ioutil"
"net/http"
"github.com/brian1917/vcodeHMAC"
)
func detailedReport(credsFile, buildID string) ([]byte, error) {
// Create HTTP client and request
client := http.Client{}
req, err := http.NewRequest("GET", "https://analysiscenter.veracode.com/api/5.0/detailedreport.do?build_id="+buildID, nil)
if err != nil {
return nil, err
}
// Set authorization header
authHeader, err := vcodeHMAC.GenerateAuthHeader(credsFile, req.Method, req.URL.String())
if err != nil {
return nil, err
}
req.Header.Set("Authorization", authHeader)
// Make HTTP Request
resp, err := client.Do(req)
if err != nil {
return nil, err
}
// Process response
data, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, err
}
if resp.Status != "200 OK" {
return nil, errors.New("detailedreport.do call error: " + resp.Status)
}
// Return data and nil error
return data, nil
}