admin: display on interface time synchronization diff

This commit is contained in:
nemunaire 2019-10-31 16:05:58 +01:00
commit 5dcb13629a
5 changed files with 48 additions and 1 deletions

26
admin/api/timestamp.go Normal file
View file

@ -0,0 +1,26 @@
package api
import (
"os"
"time"
"github.com/julienschmidt/httprouter"
)
var TimestampCheck = "submissions"
func init() {
router.GET("/api/timestamps.json", apiHandler(
func(httprouter.Params, []byte) (interface{}, error) {
if stat, err := os.Stat(TimestampCheck); err != nil {
return nil, err
} else {
now := time.Now().UTC()
return map[string]interface{}{
"frontend": stat.ModTime().UTC(),
"backend": now,
"diffFB": now.Sub(stat.ModTime()),
}, nil
}
}))
}