func (f *handler) Redirect(status int, location string) httprouter.Handle {
	return func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
		http.Redirect(w, r, location, status)
		return
	}
}
Redirect will redirect the user to given location.
package backend
import (
	"encoding/json"
	"fmt"
	"net/http"
	"sync"
	"time"
	"github.com/elazarl/go-bindata-assetfs"
	"github.com/golang/glog"
	"github.com/julienschmidt/httprouter"
	"github.com/prometheus/client_golang/prometheus/promhttp"
	"github.com/joyrex2001/nightshift/internal/webui/backend/internalfs"
)
func NewHandler() *handler {
	return &handler{}
}
type handler struct {
	once sync.Once
	mux  *httprouter.Router
}
func (f *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	f.once.Do(f.init)
	if origin := r.Header.Get("Origin"); origin != "" {
		w.Header().Set("Access-Control-Allow-Origin", origin)
	}
	f.mux.ServeHTTP(w, r)
}
func (f *handler) init() {
	f.mux = httprouter.New()
	f.mux.GET("/public/*filepath", f.Authenticate(f.ServeFiles("")))
	f.mux.GET("/api/objects", f.Authenticate(f.GetObjects))
	f.mux.POST("/api/objects/scale/:replicas", f.Authenticate(f.PostObjectsScale))
	f.mux.POST("/api/objects/restore", f.Authenticate(f.PostObjectsRestore))
	f.mux.GET("/api/scanners", f.Authenticate(f.GetScanners))
	f.mux.GET("/api/triggers", f.Authenticate(f.GetTriggers))
	f.mux.GET("/api/version", f.Authenticate(f.GetVersion))
	f.mux.GET("/metrics", f.Metrics())
	f.mux.GET("/healthz", f.Healthz)
	f.mux.GET("/", f.Redirect(307, "/public"))
}
func (f *handler) ServeFiles(folder string) httprouter.Handle {
	root := f.FileStore(folder)
	fileServer := http.FileServer(root)
	return func(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
		req.URL.Path = ps.ByName("filepath")
		fileServer.ServeHTTP(w, req)
	}
}
func (f *handler) FileStore(folder string) http.FileSystem {
	return &assetfs.AssetFS{
		Asset:     internalfs.Asset,
		AssetDir:  internalfs.AssetDir,
		AssetInfo: internalfs.AssetInfo,
		Prefix:    folder,
	}
}