-
Notifications
You must be signed in to change notification settings - Fork 5
/
list_applications_for_app_runtime.go
49 lines (41 loc) · 1.16 KB
/
list_applications_for_app_runtime.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
45
46
47
48
49
package clients
import (
models "cf-html5-apps-repo-cli-plugin/clients/models"
"cf-html5-apps-repo-cli-plugin/log"
"encoding/json"
"io/ioutil"
"net/http"
)
// ListApplicationsForAppRuntime list HTML5 applications for app-runtime
func ListApplicationsForAppRuntime(serviceURL string, accessToken string) (models.HTML5ListApplicationsResponse, error) {
var html5Response models.HTML5ListApplicationsResponse
var request *http.Request
var response *http.Response
var err error
var html5URL string
var body []byte
html5URL = serviceURL + "/applications/metadata/"
log.Tracef("Making request to: %s\n", html5URL)
client := &http.Client{}
request, err = http.NewRequest("GET", html5URL, nil)
if err != nil {
return html5Response, err
}
request.Header.Add("Authorization", "Bearer "+accessToken)
response, err = client.Do(request)
if err != nil {
return html5Response, err
}
// Get response body
defer response.Body.Close()
body, err = ioutil.ReadAll(response.Body)
if err != nil {
return html5Response, err
}
// Parse response JSON
err = json.Unmarshal(body, &html5Response)
if err != nil {
return html5Response, err
}
return html5Response, nil
}