// NewHandler gives back an HTTP handler for serving PipeCD SPA.
NewHandler gives back an HTTP handler for serving PipeCD SPA.
// NewHandler gives back an HTTP handler for serving PipeCD SPA .
func NewHandler(
	signer jwt.Signer,
	staticDir string,
	decrypter decrypter,
	address string,
	stateKey string,
	projectsInConfig map[string]config.ControlPlaneProject,
	sharedSSOConfigs map[string]*model.ProjectSSOConfig,
	projectGetter projectGetter,
	secureCookie bool,
	logger *zap.Logger,
) http.Handler {
	mux := http.NewServeMux()
	a := newAuthHandler(
		signer,
		decrypter,
		address,
		stateKey,
		projectsInConfig,
		sharedSSOConfigs,
		projectGetter,
		secureCookie,
		logger,
	)
	fs := http.FileServer(http.Dir(filepath.Join(staticDir, "assets")))
	assetsHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		w.Header().Set("Cache-Control", "public, max-age=31536000")
		http.StripPrefix("/assets/", fs).ServeHTTP(w, r)
	})
	mux.Handle("/assets/", gziphandler.GzipHandler(assetsHandler))
	mux.HandleFunc("/favicon.ico", func(w http.ResponseWriter, r *http.Request) {
		http.ServeFile(w, r, filepath.Join(staticDir, "favicon.ico"))
	})
	register := func(path string, handler http.Handler) {
		mux.Handle(path, httpapimetrics.Handler(path, handler))
	}
	register(rootPath, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		http.ServeFile(w, r, filepath.Join(staticDir, "/index.html"))
	}))
	register(loginPath, http.HandlerFunc(a.handleSSOLogin))
	register(staticLoginPath, http.HandlerFunc(a.handleStaticAdminLogin))
	register(callbackPath, http.HandlerFunc(a.handleCallback))
	register(logoutPath, http.HandlerFunc(a.handleLogout))
	return mux
}
func NewHandler ( signer jwt . Signer , staticDir string , decrypter decrypter , address string , stateKey string , projectsInConfig map [ string ] config . ControlPlaneProject , sharedSSOConfigs map [ string ] * model . ProjectSSOConfig , projectGetter projectGetter , secureCookie bool , logger * zap . Logger , ) http . Handler { mux := http . NewServeMux ( ) a := newAuthHandler ( signer , decrypter , address , stateKey , projectsInConfig , sharedSSOConfigs , projectGetter , secureCookie , logger , ) fs := http . FileServer ( http . Dir ( filepath . Join ( staticDir , " " ) ) ) assetsHandler := http . HandlerFunc ( func ( w http . ResponseWriter , r * http . Request ) { w . Header ( ) . Set ( " " , " " ) http . StripPrefix ( " " , fs ) . ServeHTTP ( w , r ) } ) mux . Handle ( " " , gziphandler . GzipHandler ( assetsHandler ) ) mux . HandleFunc ( " " , func ( w http . ResponseWriter , r * http . Request ) { http . ServeFile ( w , r , filepath . Join ( staticDir , " " ) ) } ) register := func ( path string , handler http . Handler ) { mux . Handle ( path , httpapimetrics . Handler ( path , handler ) ) } register ( rootPath , http . HandlerFunc ( func ( w http . ResponseWriter , r * http . Request ) { http . ServeFile ( w , r , filepath . Join ( staticDir , " " ) ) } ) ) register ( loginPath , http . HandlerFunc ( a . handleSSOLogin ) ) register ( staticLoginPath , http . HandlerFunc ( a . handleStaticAdminLogin ) ) register ( callbackPath , http . HandlerFunc ( a . handleCallback ) ) register ( logoutPath , http . HandlerFunc ( a . handleLogout ) ) return mux }
NewHandler gives back an HTTP handler for serving PipeCD SPA.
NewHandler gives back an HTTP handler for serving PipeCD SPA .