clean up old Gin handlers
This commit is contained in:
parent
8b4a848bc8
commit
0e46a82b05
|
@ -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",
|
||||
},
|
||||
})
|
||||
}
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue