statping/handlers/function.go

44 lines
789 B
Go
Raw Normal View History

package handlers
import (
2020-03-09 18:17:55 +00:00
"github.com/statping/statping/source"
"github.com/statping/statping/types/core"
"github.com/statping/statping/utils"
"html/template"
"net/http"
2020-02-24 05:53:15 +00:00
"net/url"
)
2020-01-13 07:11:53 +00:00
var (
basePath = "/"
)
2020-02-24 05:53:15 +00:00
func parseForm(r *http.Request) url.Values {
r.ParseForm()
return r.PostForm
}
var handlerFuncs = func(w http.ResponseWriter, r *http.Request) template.FuncMap {
return template.FuncMap{
"VERSION": func() string {
2020-03-04 10:29:00 +00:00
return core.App.Version
},
2020-02-19 08:13:09 +00:00
"CoreApp": func() core.Core {
2020-03-04 10:29:00 +00:00
c := *core.App
2020-02-19 08:13:09 +00:00
if c.Name == "" {
c.Name = "Statping"
}
return c
},
"USE_CDN": func() bool {
2020-03-04 10:29:00 +00:00
return core.App.UseCdn.Bool
},
2020-02-20 05:28:39 +00:00
"USING_ASSETS": func() bool {
2020-03-04 10:29:00 +00:00
return source.UsingAssets(utils.Directory)
2020-02-20 05:28:39 +00:00
},
2020-01-13 07:11:53 +00:00
"BasePath": func() string {
return basePath
},
}
}