mirror of
https://github.com/jhillyerd/inbucket.git
synced 2025-12-17 17:47:03 +00:00
webui: Remove unused routes/handlers
This commit is contained in:
@@ -21,55 +21,7 @@ func RootGreeting(w http.ResponseWriter, req *http.Request, ctx *web.Context) (e
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// RootMonitor serves the Inbucket monitor page
|
// RootStatus renders portions of the server configuration as JSON.
|
||||||
func RootMonitor(w http.ResponseWriter, req *http.Request, ctx *web.Context) (err error) {
|
|
||||||
if !ctx.RootConfig.Web.MonitorVisible {
|
|
||||||
ctx.Session.AddFlash("Monitor is disabled in configuration", "errors")
|
|
||||||
_ = ctx.Session.Save(req, w)
|
|
||||||
http.Redirect(w, req, web.Reverse("RootIndex"), http.StatusSeeOther)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
// Get flash messages, save session
|
|
||||||
errorFlash := ctx.Session.Flashes("errors")
|
|
||||||
if err = ctx.Session.Save(req, w); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
// Render template
|
|
||||||
return web.RenderTemplate("root/monitor.html", w, map[string]interface{}{
|
|
||||||
"ctx": ctx,
|
|
||||||
"errorFlash": errorFlash,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// RootMonitorMailbox serves the Inbucket monitor page for a particular mailbox
|
|
||||||
func RootMonitorMailbox(w http.ResponseWriter, req *http.Request, ctx *web.Context) (err error) {
|
|
||||||
if !ctx.RootConfig.Web.MonitorVisible {
|
|
||||||
ctx.Session.AddFlash("Monitor is disabled in configuration", "errors")
|
|
||||||
_ = ctx.Session.Save(req, w)
|
|
||||||
http.Redirect(w, req, web.Reverse("RootIndex"), http.StatusSeeOther)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
name, err := ctx.Manager.MailboxForAddress(ctx.Vars["name"])
|
|
||||||
if err != nil {
|
|
||||||
ctx.Session.AddFlash(err.Error(), "errors")
|
|
||||||
_ = ctx.Session.Save(req, w)
|
|
||||||
http.Redirect(w, req, web.Reverse("RootIndex"), http.StatusSeeOther)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
// Get flash messages, save session
|
|
||||||
errorFlash := ctx.Session.Flashes("errors")
|
|
||||||
if err = ctx.Session.Save(req, w); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
// Render template
|
|
||||||
return web.RenderTemplate("root/monitor.html", w, map[string]interface{}{
|
|
||||||
"ctx": ctx,
|
|
||||||
"errorFlash": errorFlash,
|
|
||||||
"name": name,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// RootStatus serves the Inbucket status page
|
|
||||||
func RootStatus(w http.ResponseWriter, req *http.Request, ctx *web.Context) (err error) {
|
func RootStatus(w http.ResponseWriter, req *http.Request, ctx *web.Context) (err error) {
|
||||||
root := ctx.RootConfig
|
root := ctx.RootConfig
|
||||||
retPeriod := ""
|
retPeriod := ""
|
||||||
|
|||||||
@@ -10,16 +10,12 @@ import (
|
|||||||
func SetupRoutes(r *mux.Router) {
|
func SetupRoutes(r *mux.Router) {
|
||||||
r.Path("/greeting").Handler(
|
r.Path("/greeting").Handler(
|
||||||
web.Handler(RootGreeting)).Name("RootGreeting").Methods("GET")
|
web.Handler(RootGreeting)).Name("RootGreeting").Methods("GET")
|
||||||
r.Path("/monitor").Handler(
|
|
||||||
web.Handler(RootMonitor)).Name("RootMonitor").Methods("GET")
|
|
||||||
r.Path("/monitor/{name}").Handler(
|
|
||||||
web.Handler(RootMonitorMailbox)).Name("RootMonitorMailbox").Methods("GET")
|
|
||||||
r.Path("/status").Handler(
|
r.Path("/status").Handler(
|
||||||
web.Handler(RootStatus)).Name("RootStatus").Methods("GET")
|
web.Handler(RootStatus)).Name("RootStatus").Methods("GET")
|
||||||
r.Path("/m/{name}/{id}").Handler(
|
r.Path("/m/{name}/{id}").Handler(
|
||||||
web.Handler(MailboxMessage)).Name("MailboxMessage").Methods("GET")
|
web.Handler(MailboxMessage)).Name("MailboxMessage").Methods("GET")
|
||||||
r.Path("/m/{name}/{id}/html").Handler(
|
r.Path("/m/{name}/{id}/html").Handler(
|
||||||
web.Handler(MailboxHTML)).Name("MailboxHtml").Methods("GET")
|
web.Handler(MailboxHTML)).Name("MailboxHTML").Methods("GET")
|
||||||
r.Path("/m/{name}/{id}/source").Handler(
|
r.Path("/m/{name}/{id}/source").Handler(
|
||||||
web.Handler(MailboxSource)).Name("MailboxSource").Methods("GET")
|
web.Handler(MailboxSource)).Name("MailboxSource").Methods("GET")
|
||||||
r.Path("/m/attach/{name}/{id}/{num}/{file}").Handler(
|
r.Path("/m/attach/{name}/{id}/{num}/{file}").Handler(
|
||||||
|
|||||||
Reference in New Issue
Block a user