forked from akamai/AkamaiOPEN-edgegrid-golang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
service.go
42 lines (32 loc) · 742 Bytes
/
service.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
package apiendpoints
import (
"net/http"
"github.com/akamai/AkamaiOPEN-edgegrid-golang/client-v1"
"github.com/akamai/AkamaiOPEN-edgegrid-golang/edgegrid"
)
var (
// Config contains the Akamai OPEN Edgegrid API credentials
// for automatic signing of requests
Config edgegrid.Config
)
// Init sets the CCU edgegrid Config
func Init(config edgegrid.Config) {
Config = config
}
func call(req *http.Request, err error) (*Endpoint, error) {
if err != nil {
return nil, err
}
res, err := client.Do(Config, req)
if err != nil {
return nil, err
}
if client.IsError(res) {
return nil, client.NewAPIError(res)
}
rep := &Endpoint{}
if err = client.BodyJSON(res, rep); err != nil {
return nil, err
}
return rep, nil
}