mirror of
https://github.com/jhillyerd/inbucket.git
synced 2025-12-18 01:57:02 +00:00
- Rename BUILD_DATE to BUILDDATE in goxc - Update travis config - Follow linter recommendations for inbucket.go - Follow linter recommendations for config package - Follow linter recommendations for log package - Follow linter recommendations for pop3d package - Follow linter recommendations for smtpd package - Follow linter recommendations for web package - Fix Id -> ID in templates - Add shebang to REST demo scripts - Add or refine many comments
44 lines
1.4 KiB
Go
44 lines
1.4 KiB
Go
package web
|
|
|
|
import (
|
|
"fmt"
|
|
"html/template"
|
|
"io/ioutil"
|
|
"net/http"
|
|
|
|
"github.com/jhillyerd/inbucket/config"
|
|
)
|
|
|
|
// RootIndex serves the Inbucket landing page
|
|
func RootIndex(w http.ResponseWriter, req *http.Request, ctx *Context) (err error) {
|
|
greeting, err := ioutil.ReadFile(config.GetWebConfig().GreetingFile)
|
|
if err != nil {
|
|
return fmt.Errorf("Failed to load greeting: %v", err)
|
|
}
|
|
|
|
return RenderTemplate("root/index.html", w, map[string]interface{}{
|
|
"ctx": ctx,
|
|
"greeting": template.HTML(string(greeting)),
|
|
})
|
|
}
|
|
|
|
// RootStatus serves the Inbucket status page
|
|
func RootStatus(w http.ResponseWriter, req *http.Request, ctx *Context) (err error) {
|
|
retentionMinutes := config.GetDataStoreConfig().RetentionMinutes
|
|
smtpListener := fmt.Sprintf("%s:%d", config.GetSMTPConfig().IP4address.String(),
|
|
config.GetSMTPConfig().IP4port)
|
|
pop3Listener := fmt.Sprintf("%s:%d", config.GetPOP3Config().IP4address.String(),
|
|
config.GetPOP3Config().IP4port)
|
|
webListener := fmt.Sprintf("%s:%d", config.GetWebConfig().IP4address.String(),
|
|
config.GetWebConfig().IP4port)
|
|
return RenderTemplate("root/status.html", w, map[string]interface{}{
|
|
"ctx": ctx,
|
|
"version": config.Version,
|
|
"buildDate": config.BuildDate,
|
|
"retentionMinutes": retentionMinutes,
|
|
"smtpListener": smtpListener,
|
|
"pop3Listener": pop3Listener,
|
|
"webListener": webListener,
|
|
})
|
|
}
|