clean up old Gin handlers

This commit is contained in:
f0x 2022-09-07 13:55:00 +02:00
parent 8b4a848bc8
commit 0e46a82b05
2 changed files with 2 additions and 62 deletions

View file

@ -49,52 +49,3 @@ func (m *Module) SettingsPanelHandler(c *gin.Context) {
},
})
}
func (m *Module) UserPanelHandler(c *gin.Context) {
host := config.GetHost()
instance, err := m.processor.InstanceGet(c.Request.Context(), host)
if err != nil {
api.ErrorHandler(c, gtserror.NewErrorInternalError(err), m.processor.InstanceGet)
return
}
c.HTML(http.StatusOK, "frontend.tmpl", gin.H{
"instance": instance,
"stylesheets": []string{
assetsPathPrefix + "/Fork-Awesome/css/fork-awesome.min.css",
assetsPathPrefix + "/dist/_colors.css",
assetsPathPrefix + "/dist/base.css",
assetsPathPrefix + "/dist/panels-base.css",
assetsPathPrefix + "/dist/panels-user-style.css",
},
"javascript": []string{
assetsPathPrefix + "/dist/bundle.js",
assetsPathPrefix + "/dist/user-panel.js",
},
})
}
// TODO: abstract the {admin, user}panel handlers in some way
func (m *Module) AdminPanelHandler(c *gin.Context) {
host := config.GetHost()
instance, err := m.processor.InstanceGet(c.Request.Context(), host)
if err != nil {
api.ErrorHandler(c, gtserror.NewErrorInternalError(err), m.processor.InstanceGet)
return
}
c.HTML(http.StatusOK, "frontend.tmpl", gin.H{
"instance": instance,
"stylesheets": []string{
assetsPathPrefix + "/Fork-Awesome/css/fork-awesome.min.css",
assetsPathPrefix + "/dist/_colors.css",
assetsPathPrefix + "/dist/base.css",
assetsPathPrefix + "/dist/panels-base.css",
assetsPathPrefix + "/dist/panels-admin-style.css",
},
"javascript": []string{
assetsPathPrefix + "/dist/bundle.js",
assetsPathPrefix + "/dist/admin-panel.js",
},
})
}

View file

@ -70,23 +70,12 @@ func (m *Module) Route(s router.Router) error {
assetsGroup := s.AttachGroup(assetsPathPrefix)
m.mountAssetsFilesystem(assetsGroup)
s.AttachHandler(http.MethodGet, adminPanelPath, m.AdminPanelHandler)
// redirect /admin/ to /admin
s.AttachHandler(http.MethodGet, adminPanelPath+"/", func(c *gin.Context) {
c.Redirect(http.StatusMovedPermanently, adminPanelPath)
})
s.AttachHandler(http.MethodGet, "/settings", m.SettingsPanelHandler)
s.AttachHandler(http.MethodGet, "/settings/*panel", m.SettingsPanelHandler)
s.AttachHandler(http.MethodGet, userPanelpath, m.UserPanelHandler)
// redirect /user/ to /user
s.AttachHandler(http.MethodGet, userPanelpath+"/", func(c *gin.Context) {
c.Redirect(http.StatusMovedPermanently, userPanelpath)
})
// redirect /auth/edit to /user
// redirect /auth/edit to /settings/user
s.AttachHandler(http.MethodGet, "/auth/edit", func(c *gin.Context) {
c.Redirect(http.StatusMovedPermanently, userPanelpath)
c.Redirect(http.StatusMovedPermanently, "/settings/user")
})
// serve front-page