func InitHTTP(config HTTPConfig, controller *FileController) {
	router := httprouter.New()
	auth := noAuth
	if config.HTTPS {
		auth = basicAuth
	}
	router.GET("/healthz", health)
	router.GET("/bucketrepo/*filepath", auth(controller.GetFile, config))
	router.HEAD("/bucketrepo/*filepath", auth(controller.GetFile, config))
	router.PUT("/bucketrepo/*filepath", auth(controller.PutFile, config))
	if config.ChartPath != "" {
		router.POST(URLJoin("/bucketrepo", config.ChartPath, "/api/charts"), auth(controller.PostChart, config))
	}
	log.Infof("Starting http server on %q", config.Address)
	if config.HTTPS {
		log.Fatal(http.ListenAndServeTLS(config.Address, config.Certificate, config.Key, router))
		return
	}
	log.Fatal(http.ListenAndServe(config.Address, router))
}
InitHTTP initializes the HTTP server routes
package main
import (
	"fmt"
	"net/http"
	"github.com/julienschmidt/httprouter"
	log "github.com/sirupsen/logrus"
)
func basicAuth(h httprouter.Handle, config HTTPConfig) httprouter.Handle {
	return func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
		user, password, hasAuth := r.BasicAuth()
		if hasAuth && user == config.Username && password == config.Password {
			h(w, r, ps)
		} else {
			w.Header().Set("WWW-Authenticate", "Basic realm=Restricted")
			http.Error(w, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized)
		}
	}
}
func noAuth(h httprouter.Handle, config HTTPConfig) httprouter.Handle {
	return func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
		h(w, r, ps)
	}
}
func health(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
	fmt.Fprintf(w, "OK")
}