2015-09-04 13:36:49 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
//go:generate go-bindata display.html
|
|
|
|
|
|
|
|
import (
|
2015-09-04 13:54:08 +00:00
|
|
|
"encoding/json"
|
2015-09-04 13:36:49 +00:00
|
|
|
"log"
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/flosch/pongo2"
|
|
|
|
)
|
|
|
|
|
2015-09-04 13:54:08 +00:00
|
|
|
func htmlHandler(res http.ResponseWriter, r *http.Request) {
|
2015-09-04 13:36:49 +00:00
|
|
|
tplsrc, _ := Asset("display.html")
|
|
|
|
|
|
|
|
template, err := pongo2.FromString(string(tplsrc))
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
template.ExecuteWriter(pongo2.Context{
|
|
|
|
"results": probeMonitors,
|
|
|
|
"certificateOK": certificateOK,
|
|
|
|
"certificateExpiresSoon": certificateExpiresSoon,
|
|
|
|
"version": version,
|
|
|
|
}, res)
|
|
|
|
}
|
2015-09-04 13:54:08 +00:00
|
|
|
|
|
|
|
func jsonHandler(res http.ResponseWriter, r *http.Request) {
|
|
|
|
res.Header().Set("Content-Type", "application/json")
|
|
|
|
json.NewEncoder(res).Encode(probeMonitors)
|
|
|
|
}
|