package dashboard import ( "net/http" "github.com/xlgmokha/x/pkg/context" "github.com/xlgmokha/x/pkg/x" "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/domain" ) var CurrentUserKey context.Key[*domain.User] = context.Key[*domain.User]("current_user") type Controller struct { } func New() *Controller { return &Controller{} } func (c *Controller) MountTo(mux *http.ServeMux) { mux.HandleFunc("GET /dashboard", c.Show) } func (c *Controller) Show(w http.ResponseWriter, r *http.Request) { currentUser := CurrentUserKey.From(r.Context()) if x.IsZero(currentUser) { http.Redirect(w, r, "/", http.StatusFound) return } w.WriteHeader(http.StatusOK) w.Header().Add("Content-Type", "text/html") }