-
Notifications
You must be signed in to change notification settings - Fork 0
/
web.go
45 lines (34 loc) · 747 Bytes
/
web.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
package main
import (
api "github.com/andrewmagv/wowza-streaming-agent/api"
log "github.com/Sirupsen/logrus"
"encoding/json"
"errors"
"net/http"
)
const (
DefaultInfoURI = "http://ambassador:29091/info"
)
var (
ErrNodeInfoNotFound = errors.New("key not in info")
)
func runAPIEndpoint(addr string, stop chan<- struct{}) {
defer close(stop)
server := api.GetServer()
server.Addr = addr
log.Error(server.ListenAndServe())
}
func getNodeInfo() (map[string]string, error) {
resp, err := http.Get(DefaultInfoURI)
if err != nil {
return nil, err
}
defer resp.Body.Close()
var info = make(map[string]string)
err = json.NewDecoder(resp.Body).Decode(&info)
if err != nil {
return nil, err
} else {
return info, nil
}
}