Add raw Supervisor API response to frigate check endpoint
This commit is contained in:
@@ -40,6 +40,7 @@ func apiCheck(w http.ResponseWriter, r *http.Request) {
|
|||||||
result["detection"] = "env"
|
result["detection"] = "env"
|
||||||
} else if os.Getenv("SUPERVISOR_TOKEN") != "" {
|
} else if os.Getenv("SUPERVISOR_TOKEN") != "" {
|
||||||
result["detection"] = "supervisor"
|
result["detection"] = "supervisor"
|
||||||
|
result["supervisor_token_len"] = len(os.Getenv("SUPERVISOR_TOKEN"))
|
||||||
// show what addons we found
|
// show what addons we found
|
||||||
addons, frigateSlug := listHAAddons()
|
addons, frigateSlug := listHAAddons()
|
||||||
result["ha_addons"] = addons
|
result["ha_addons"] = addons
|
||||||
@@ -141,7 +142,7 @@ func findFrigateAddon(token string) string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// listHAAddons returns raw JSON from Supervisor API for debug
|
// listHAAddons returns raw response from Supervisor API for debug
|
||||||
func listHAAddons() (any, string) {
|
func listHAAddons() (any, string) {
|
||||||
token := os.Getenv("SUPERVISOR_TOKEN")
|
token := os.Getenv("SUPERVISOR_TOKEN")
|
||||||
if token == "" {
|
if token == "" {
|
||||||
@@ -163,9 +164,10 @@ func listHAAddons() (any, string) {
|
|||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
var raw any
|
var raw any
|
||||||
if err = json.NewDecoder(resp.Body).Decode(&raw); err != nil {
|
json.NewDecoder(resp.Body).Decode(&raw)
|
||||||
return map[string]string{"error": err.Error()}, ""
|
|
||||||
}
|
|
||||||
|
|
||||||
return raw, ""
|
return map[string]any{
|
||||||
|
"status_code": resp.StatusCode,
|
||||||
|
"body": raw,
|
||||||
|
}, ""
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user