eq performance

This commit is contained in:
samantha42
2026-06-02 00:16:03 +02:00
parent f2cf27c76f
commit 9b8d624be9
5 changed files with 185 additions and 6 deletions
+12 -2
View File
@@ -19,8 +19,9 @@ import (
)
type Config struct {
Job string `json:"job"`
Emails []string `json:"emails"`
Job string `json:"job"`
Emails []string `json:"emails"`
NewsSent int `json:"newletter-sent"`
}
func loadConfig() (*Config, error) {
@@ -187,6 +188,15 @@ func main() {
fmt.Fprintf(w, "%s", strconv.Itoa(len(conf.Emails)))
}))
apiMux.HandleFunc("GET /stats/sent", requireAuth(func(w http.ResponseWriter, r *http.Request) {
conf, err := loadConfig()
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
fmt.Fprintf(w, "%s", strconv.Itoa(conf.NewsSent))
}))
// strip /admin/api before handing off
adminMux.Handle("/api/", http.StripPrefix("/api", apiMux))