diff --git a/handlers/cache.go b/handlers/cache.go
index 0a8c4364..e3c103aa 100644
--- a/handlers/cache.go
+++ b/handlers/cache.go
@@ -14,6 +14,7 @@ type Cacher interface {
Get(key string) []byte
Delete(key string)
Set(key string, content []byte, duration time.Duration)
+ List() map[string]Item
}
// Item is a cached reference
@@ -44,6 +45,10 @@ func NewStorage() *Storage {
}
}
+func (s Storage) List() map[string]Item {
+ return s.items
+}
+
//Get a cached content by key
func (s Storage) Get(key string) []byte {
item := s.items[key]
diff --git a/handlers/functions.go b/handlers/functions.go
index c1b7361a..2790b7fb 100644
--- a/handlers/functions.go
+++ b/handlers/functions.go
@@ -82,6 +82,9 @@ var handlerFuncs = func(w http.ResponseWriter, r *http.Request) template.FuncMap
"Error": func() string {
return ""
},
+ "Cache": func() Cacher {
+ return CacheStorage
+ },
"ToString": func(v interface{}) string {
return utils.ToString(v)
},
@@ -98,6 +101,12 @@ var handlerFuncs = func(w http.ResponseWriter, r *http.Request) template.FuncMap
"FromUnix": func(t int64) string {
return utils.Timezoner(time.Unix(t, 0), core.CoreApp.Timezone).Format("Monday, January 02")
},
+ "UnixTime": func(t int64, nano bool) string {
+ if nano {
+ t = t / 1e9
+ }
+ return utils.Timezoner(time.Unix(t, 0), core.CoreApp.Timezone).String()
+ },
"NewService": func() *types.Service {
return new(types.Service)
},
diff --git a/source/tmpl/settings.gohtml b/source/tmpl/settings.gohtml
index 8c3d3c9d..7678084c 100644
--- a/source/tmpl/settings.gohtml
+++ b/source/tmpl/settings.gohtml
@@ -8,6 +8,7 @@
Settings
Theme Editor
+
Cache
{{ range .Notifications }}
{{.Select.Method}}
{{ end }}
@@ -125,7 +126,6 @@
Additional Settings
+
+
Cache
+
+
+
+ URL |
+ Size |
+ Expiration |
+
+
+
+ {{ range $key, $value := Cache.List }}
+
+ {{$key}} |
+ {{len $value.Content}} |
+ {{UnixTime $value.Expiration true}} |
+
+ {{end}}
+
+
+
Clear Cache
+
{{ range .Notifications }}
{{$n := .Select}}
diff --git a/source/wiki.go b/source/wiki.go
index 7b2e285d..c22b7518 100644
--- a/source/wiki.go
+++ b/source/wiki.go
@@ -1,6 +1,6 @@
// Code generated by go generate; DO NOT EDIT.
// This file was generated by robots at
-// 2019-02-01 11:55:53.781812 -0800 PST m=+0.615412774
+// 2019-02-01 12:26:35.052075 -0800 PST m=+0.640410556
//
// This contains the most recently Markdown source for the Statping Wiki.
package source
diff --git a/utils/utils.go b/utils/utils.go
index 753a7915..40f1a095 100644
--- a/utils/utils.go
+++ b/utils/utils.go
@@ -247,24 +247,24 @@ func HttpRequest(url, method string, content interface{}, headers []string, body
Transport: transport,
Timeout: timeout,
}
- r := new(http.Request)
+ var req *http.Request
+ if req, err = http.NewRequest(method, url, body); err != nil {
+ return nil, nil, err
+ }
+ req.Header.Set("User-Agent", "Statping")
+ if content != nil {
+ req.Header.Set("Content-Type", content.(string))
+ }
for _, h := range headers {
keyVal := strings.Split(h, "=")
if len(keyVal) == 2 {
if keyVal[0] != "" && keyVal[1] != "" {
- r.Header.Add(keyVal[0], keyVal[1])
+ req.Header.Set(keyVal[0], keyVal[1])
}
}
}
- if r, err = http.NewRequest(method, url, body); err != nil {
- return nil, nil, err
- }
- r.Header.Set("User-Agent", "Statping")
- if content != nil {
- r.Header.Set("Content-Type", content.(string))
- }
var resp *http.Response
- if resp, err = client.Do(r); err != nil {
+ if resp, err = client.Do(req); err != nil {
return nil, resp, err
}
defer resp.Body.Close()
diff --git a/version.txt b/version.txt
index a5272278..b0a9729f 100644
--- a/version.txt
+++ b/version.txt
@@ -1 +1 @@
-0.80.42
+0.80.43