Skip to content

Commit 241e4ac

Browse files
committed
nonexistent_secrets_read was counted incorrectly
1 parent 9579b6d commit 241e4ac

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

main.go

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ func init() {
5050

5151
func secretCleaner() {
5252
for {
53+
time.Sleep(5 * time.Minute)
5354
secretStore.Lock.RLock()
5455
for k, v := range secretStore.Data {
5556
s, err := Decrypt(v, k)
@@ -64,7 +65,6 @@ func secretCleaner() {
6465
}
6566
}
6667
secretStore.Lock.RUnlock()
67-
time.Sleep(5 * time.Minute)
6868
}
6969
}
7070

@@ -78,12 +78,13 @@ func main() {
7878
fs := http.FileServer(http.Dir("./static"))
7979
r.PathPrefix("/js/").Handler(fs)
8080
r.PathPrefix("/css/").Handler(fs)
81+
r.PathPrefix("/favicon.ico").Handler(fs)
8182
r.PathPrefix("/robots.txt").Handler(fs)
8283
// End of static stuff
8384

8485
r.HandleFunc("/", IndexHandler).Methods("GET")
8586
r.HandleFunc("/", NewHandler).Methods("POST")
86-
r.Handle("/metrics", promhttp.HandlerFor(pr, promhttp.HandlerOpts{})).Methods("GET")
87+
r.PathPrefix("/metrics").Handler(promhttp.HandlerFor(pr, promhttp.HandlerOpts{})).Methods("GET")
8788
// r.HandleFunc("/metrics", promhttp.Handler()).Methods("GET")
8889
r.HandleFunc("/{id}", GetHandler).Methods("GET")
8990

@@ -126,10 +127,6 @@ func GetHandler(w http.ResponseWriter, r *http.Request) {
126127
}
127128

128129
if useHtml {
129-
_, hasData := secretStore.Data[vars["id"]]
130-
if !hasData {
131-
w.WriteHeader(http.StatusGone)
132-
}
133130
newError := templates["read"].Execute(w, Page{Startup: startupTime})
134131
if newError != nil {
135132
fmt.Fprintf(w, "%s", newError)
@@ -149,9 +146,3 @@ func GetHandler(w http.ResponseWriter, r *http.Request) {
149146
w.WriteHeader(http.StatusOK)
150147
fmt.Fprintf(w, "%s", secretData)
151148
}
152-
153-
func MetricsHandler(w http.ResponseWriter, r *http.Request) {
154-
w.WriteHeader(http.StatusOK)
155-
156-
fmt.Fprintf(w, "%d", len(secretStore.Data))
157-
}

0 commit comments

Comments
 (0)