forked from Cliffbreak/tsviewer
33 lines
683 B
Go
33 lines
683 B
Go
|
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)
|
||
|
})
|
||
|
}
|