Feat v0.6.17 bugfixes (#52)
Co-authored-by: Jeffrey Smith <jasafpro@gmail.com> Co-committed-by: Jeffrey Smith <jasafpro@gmail.com>
This commit was merged in pull request #52.
This commit is contained in:
@@ -494,6 +494,10 @@ func (e *Engine) RegisterPageRoutes(base *gin.RouterGroup, mw PageRouteMiddlewar
|
||||
continue
|
||||
}
|
||||
handler := e.RenderSurface(s.ID)
|
||||
// Welcome auto-redirects to / when extension surfaces exist
|
||||
if s.ID == "welcome" {
|
||||
handler = e.welcomeRedirectIfSurfaces(handler)
|
||||
}
|
||||
registerRoutes(group, s, handler)
|
||||
}
|
||||
|
||||
|
||||
@@ -176,6 +176,28 @@ func (e *Engine) surfacePath(ctx context.Context, id string) string {
|
||||
return "/s/" + id
|
||||
}
|
||||
|
||||
// welcomeRedirectIfSurfaces wraps a welcome surface handler so that
|
||||
// /welcome auto-redirects to / when any extension surface is installed.
|
||||
// This means the welcome page only renders for truly empty deployments.
|
||||
func (e *Engine) welcomeRedirectIfSurfaces(inner gin.HandlerFunc) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
if e.stores.Packages != nil {
|
||||
if pkgs, err := e.stores.Packages.List(c.Request.Context()); err == nil {
|
||||
for _, p := range pkgs {
|
||||
if p.Source == "core" || !p.Enabled {
|
||||
continue
|
||||
}
|
||||
if p.Type == "surface" || p.Type == "full" {
|
||||
c.Redirect(http.StatusTemporaryRedirect, e.cfg.BasePath+"/")
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
inner(c)
|
||||
}
|
||||
}
|
||||
|
||||
// disabledRedirect returns a handler that redirects to /.
|
||||
// The DefaultSurfaceRedirect handler will resolve to the appropriate surface.
|
||||
func (e *Engine) disabledRedirect() gin.HandlerFunc {
|
||||
|
||||
Reference in New Issue
Block a user