code reorg

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-10-29 09:02:15 -05:00
parent 8724a07b0d
commit 9d08114b93
1 changed files with 13 additions and 38 deletions

51
http.go
View File

@ -6,7 +6,6 @@ import (
"os"
"strings"
pb "go.wit.com/lib/protobuf/virtbuf"
"go.wit.com/lib/virtigoxml"
"go.wit.com/log"
)
@ -21,43 +20,6 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
var route string
route = cleanURL(r.URL.Path)
// show only what droplets should be running but are missing
if route == "/missing" {
var count int
var missing int
for _, d := range me.cluster.Droplets {
if d.StartState != pb.DropletState_ON {
continue
}
count += 1
if d.CurrentState == pb.DropletState_ON {
continue
}
missing += 1
fmt.Fprintln(w, d.Hostname, "current state:", d.CurrentState)
}
if missing == 0 {
fmt.Fprintln(w, "all", count, "droplets set to run are running")
} else {
fmt.Fprintln(w, missing, "droplets missing")
fmt.Fprintln(w, count, "droplets should be running")
}
return
}
if route == "/favicon.ico" {
// w.Header().Set("Content-Type", "image/svg+xml")
w.Header().Set("Content-Type", "image/png")
writeFile(w, "ipv6.png")
return
}
if route == "/goReference.svg" {
w.Header().Set("Content-Type", "image/svg+xml")
writeFile(w, "goReference.svg")
return
}
if route == "/uptime" {
ok, s := uptimeCheck()
if ok {
@ -143,6 +105,19 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
return
}
if route == "/favicon.ico" {
// w.Header().Set("Content-Type", "image/svg+xml")
w.Header().Set("Content-Type", "image/png")
writeFile(w, "ipv6.png")
return
}
if route == "/goReference.svg" {
w.Header().Set("Content-Type", "image/svg+xml")
writeFile(w, "goReference.svg")
return
}
log.Warn("BAD URL =", route)
fmt.Fprintln(w, "BAD URL tmp =", route)
}