feat: data store

This commit is contained in:
trafficlunar 2025-03-22 12:05:19 +00:00
parent 4f8ee6cf9c
commit 19bdd27de1
8 changed files with 123 additions and 53 deletions

View file

@ -2,12 +2,16 @@ package handler
import (
"api/internal/service"
"api/internal/storage"
"encoding/json"
"net/http"
)
func HandleGetHitCounter(w http.ResponseWriter, r *http.Request) {
data := service.GetHitCounter()
data := storage.GlobalDataStore.Get("hits")
if data == nil {
data = 0
}
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(data)