mirror of
https://github.com/project-zot/zot.git
synced 2024-12-23 22:27:35 -05:00
ed4954ab0d
Update the default value of the EXTENSIONS variable in the makefile. Also cleanup binary-ui and other make targets assuming the UI was not included by default. Enable the ui by default in the zot container image Swith back to using the distroless images, as c3 only has amd64 images. Fix updating security events in github (permission issue) Add an integration test for the UI extension Rename ui extension files to use _ instead of - feat(ui): upgrade to zui v2.0.0-rc3 Signed-off-by: Andrei Aaron <aaaron@luxoft.com>
51 lines
1.1 KiB
Go
51 lines
1.1 KiB
Go
//go:build search && ui
|
|
// +build search,ui
|
|
|
|
package extensions
|
|
|
|
import (
|
|
"embed"
|
|
"io/fs"
|
|
"net/http"
|
|
|
|
"github.com/gorilla/mux"
|
|
|
|
"zotregistry.io/zot/pkg/api/config"
|
|
"zotregistry.io/zot/pkg/log"
|
|
"zotregistry.io/zot/pkg/storage"
|
|
)
|
|
|
|
// content is our static web server content.
|
|
//
|
|
//go:embed build/*
|
|
var content embed.FS
|
|
|
|
type uiHandler struct {
|
|
log log.Logger
|
|
}
|
|
|
|
func (uih uiHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|
buf, _ := content.ReadFile("build/index.html")
|
|
|
|
_, err := w.Write(buf)
|
|
if err != nil {
|
|
uih.log.Error().Err(err).Msg("unable to serve index.html")
|
|
}
|
|
}
|
|
|
|
func SetupUIRoutes(config *config.Config, router *mux.Router, storeController storage.StoreController,
|
|
log log.Logger,
|
|
) {
|
|
if config.Extensions.UI != nil {
|
|
fsub, _ := fs.Sub(content, "build")
|
|
uih := uiHandler{log: log}
|
|
|
|
router.PathPrefix("/login").Handler(uih)
|
|
router.PathPrefix("/home").Handler(uih)
|
|
router.PathPrefix("/explore").Handler(uih)
|
|
router.PathPrefix("/image").Handler(uih)
|
|
router.PathPrefix("/").Handler(http.FileServer(http.FS(fsub)))
|
|
|
|
log.Info().Msg("setting up ui routes")
|
|
}
|
|
}
|