tsviewer/features/web/index/handler.go

33 lines
683 B
Go
Raw Normal View History

2019-01-21 17:53:33 +00:00
package index
import (
"html/template"
"net/http"
"git.cliffbreak.de/Cliffbreak/tsviewer/features/web/weberror"
)
func IndexGUIHandler(s Service, t template.Template) http.HandlerFunc {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
server, err := s.ServerInfo()
if err != nil {
weberror.NewPage(err, http.StatusNotFound).Send(w, t)
return
}
channels, err := s.Channels()
if err != nil {
weberror.NewPage(err, http.StatusNotFound).Send(w, t)
return
}
clients, err := s.Clients()
if err != nil {
weberror.NewPage(err, http.StatusNotFound).Send(w, t)
return
}
NewPage(*server, channels, clients).Send(w, t)
})
}