Added Config file #10
10
main.go
10
main.go
@ -68,7 +68,7 @@ func processUcAPIs(c Config) ([]node, []link) {
|
||||
//get list of Unifi devices to display
|
||||
var nodes []node
|
||||
var links []link
|
||||
d, err := getDevices(c, "ucDevices.json")
|
||||
d, err := getDevices(c.Unifi.UCDevicesURL)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
@ -153,7 +153,7 @@ func processUNMSAPI(c Config) ([]node, []link) {
|
||||
var links []link
|
||||
var nodes []node
|
||||
|
||||
d, err := getDevices(c, "devices.json")
|
||||
d, err := getDevices(c.Unms.DevicesURL)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
@ -279,9 +279,9 @@ func getFile(url string) []byte {
|
||||
return byteValue
|
||||
}
|
||||
|
||||
func getDevices(c Config, file string) (devices, error) {
|
||||
func getDevices(url string) (devices, error) {
|
||||
// get devices from JSON file
|
||||
jsonFile := getFile(c.Unms.DevicesURL + file)
|
||||
jsonFile := getFile(url)
|
||||
|
||||
// read file to bytes
|
||||
// variable for d
|
||||
@ -289,7 +289,7 @@ func getDevices(c Config, file string) (devices, error) {
|
||||
// unmarshal to struct
|
||||
err := json.Unmarshal(jsonFile, &d)
|
||||
if err != nil {
|
||||
fmt.Println("can´t get devices file from " + c.Unms.DevicesURL)
|
||||
fmt.Println("can´t get devices file from " + url)
|
||||
log.Fatal(err)
|
||||
}
|
||||
return d, nil
|
||||
|
Loading…
Reference in New Issue
Block a user