diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2026-06-28 15:44:06 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2026-06-28 15:45:37 +0200 |
| commit | 2d12f1d9a8ec4a6604dc4de119aace633043b29e (patch) | |
| tree | fc20e0f9a37d46a0d45d8a3327e6686e9d971a81 /main.go | |
| parent | bf4c9866949a24ebbccdc488a8543a2e4e0f444c (diff) | |
| download | ticket-counter-2d12f1d9a8ec4a6604dc4de119aace633043b29e.tar.gz ticket-counter-2d12f1d9a8ec4a6604dc4de119aace633043b29e.zip | |
use the server startup time to drop old cached tickets
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -9,6 +9,7 @@ import ( "net/http" "strconv" "sync/atomic" + "time" ) //go:embed index.html @@ -18,6 +19,7 @@ var pageTemplate *template.Template var open atomic.Uint64 var done atomic.Uint64 +var start time.Time var broker *Broker @@ -144,10 +146,11 @@ func pageHandler(w http.ResponseWriter, r *http.Request) { } tempData := struct { - Open uint64 - Done uint64 - IsAdmin bool - }{open.Load(), done.Load() + 1, r.URL.Query().Has(*passwd)} + Open uint64 + Done uint64 + StartTime string + IsAdmin bool + }{open.Load(), done.Load() + 1, start.Format(time.RFC3339), r.URL.Query().Has(*passwd)} if err := pageTemplate.Execute(w, tempData); err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) @@ -178,6 +181,8 @@ var passwd = flag.String("password", "admin", "the admin password") func main() { flag.Parse() + start = time.Now() + broker = &Broker{ make(map[chan string]bool), make(chan (chan string)), |
