chirpy_server/reset.go
2024-10-23 22:16:51 +02:00

21 lines
390 B
Go

package main
import (
"log"
"net/http"
)
func (cfg *apiConfig) serveReset(w http.ResponseWriter, r *http.Request) {
cfg.fileserverHits.Store(0)
if cfg.Platform != "dev" {
log.Printf("Invalid %s platform !", cfg.Platform)
w.WriteHeader(http.StatusForbidden)
return
}
_, err := cfg.DB.DeleteUser(r.Context())
if err != nil {
log.Printf("Error deleting users: %s", err)
}
}