forked from fabiolb/fabio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.go
32 lines (28 loc) · 916 Bytes
/
server.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
package admin
import (
"fmt"
"net/http"
"github.com/eBay/fabio/admin/api"
"github.com/eBay/fabio/admin/ui"
"github.com/eBay/fabio/config"
)
// ListenAndServe starts the admin api and ui server.
func ListenAndServe(cfg *config.Config, version string) error {
ui.Version = version
ui.Color = cfg.UI.Color
ui.Title = cfg.UI.Title
api.Cfg = cfg
api.Version = version
http.HandleFunc("/api/config", api.HandleConfig)
http.HandleFunc("/api/manual", api.HandleManual)
http.HandleFunc("/api/routes", api.HandleRoutes)
http.HandleFunc("/api/version", api.HandleVersion)
http.HandleFunc("/manual", ui.HandleManual)
http.HandleFunc("/routes", ui.HandleRoutes)
http.HandleFunc("/health", handleHealth)
http.Handle("/", http.RedirectHandler("/routes", http.StatusSeeOther))
return http.ListenAndServe(cfg.UI.Addr, nil)
}
func handleHealth(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "OK")
}