main.go 702 B

123456789101112131415161718192021222324252627
  1. package main
  2. import (
  3. "net/http"
  4. "github.com/julienschmidt/httprouter"
  5. "github.com/kubecost/cost-model/pkg/costmodel"
  6. "github.com/kubecost/cost-model/pkg/errors"
  7. "github.com/prometheus/client_golang/prometheus/promhttp"
  8. "k8s.io/klog"
  9. )
  10. func Healthz(w http.ResponseWriter, _ *http.Request, _ httprouter.Params) {
  11. w.WriteHeader(200)
  12. w.Header().Set("Content-Length", "0")
  13. w.Header().Set("Content-Type", "text/plain")
  14. }
  15. func main() {
  16. a := costmodel.Initialize()
  17. rootMux := http.NewServeMux()
  18. a.Router.GET("/healthz", Healthz)
  19. rootMux.Handle("/", a.Router)
  20. rootMux.Handle("/metrics", promhttp.Handler())
  21. klog.Fatal(http.ListenAndServe(":9003", errors.PanicHandlerMiddleware(rootMux)))
  22. }