main.go 633 B

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