From 2c42e35c63f77b613a9f9df10770e627f20ef9a4 Mon Sep 17 00:00:00 2001 From: Arnas Udovic Date: Thu, 18 Jul 2024 14:45:29 +0300 Subject: [PATCH] page counter per lang --- main.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/main.go b/main.go index 0b11463..1e59fbd 100644 --- a/main.go +++ b/main.go @@ -136,7 +136,7 @@ func process(_ context.Context, w gemini.ResponseWriter, r *gemini.Request) { log.Fatal(err) return } - db.Inc("page_counter") + db.Inc("page_counter" + defaultLang) conn, err := grpc.Dial( fileSrvHost+":"+fileSrvPort, @@ -238,14 +238,12 @@ func renderIndex(w gemini.ResponseWriter, client TreeManagerClient) { lastRebuild, found := db.Get("last_rebuild") if !found { - w.WriteHeader(gemini.StatusTemporaryFailure, "Internal server error") - return } - pageCounter, found := db.Get("page_counter") + pageCounter, found := db.Get("page_counter_" + defaultLang) if !found { - w.WriteHeader(gemini.StatusTemporaryFailure, "Internal server error") - return + pageCounter = "1" + db.Save("page_counter_"+defaultLang, "1") } w.SetMediaType("text/gemini")