-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathserve.go
34 lines (26 loc) · 852 Bytes
/
serve.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
package kunsul
import (
"fmt"
"net/http"
log "github.com/sirupsen/logrus"
"k8s.io/client-go/rest"
)
var (
code int = http.StatusTemporaryRedirect
)
func Serve(kubeConfig *rest.Config, configDir string, templateFile string, listenPort int, accessLog bool, ingressLabels []string) {
log.Info("initialize kunsul")
log.Debug("debug logging enabled")
http.HandleFunc("/health", healthCheckHandler)
http.HandleFunc("/health/", healthCheckHandler)
log.WithFields(log.Fields{
"configDir": configDir,
"port": listenPort,
"templateFile": templateFile,
"ingressLabels": ingressLabels,
}).Info("listening for requests")
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
render(w, r, kubeConfig, configDir, templateFile, ingressLabels)
})
http.ListenAndServe(":"+fmt.Sprintf("%v", listenPort), nil)
}