package main import ( "fmt" "net/http" ) func gameDelete(w http.ResponseWriter, r *http.Request) { if unauthorizedIfNotLocal(w, r) { return } err := r.ParseForm() if err != nil { Logger.Printf("Installer: While parsing form: %s", err) http.Error(w, fmt.Sprintf("Invalid form: %s", err), 400) return } game := r.PostForm.Get("name") if game == "" { Logger.Println("Deleter: No game specified") http.Error(w, "Game param required", 400) return } Lib.Lock() g, ok := Lib.Games[game] Lib.Unlock() if !ok { Logger.Printf("Missing: %s", game) http.Error(w, "Game is missing", 404) return } err = g.Delete() if err != nil { Logger.Printf("Error removing game: %s", err) http.Error(w, fmt.Sprintf("Error removing game: %s", err), 500) return } Logger.Printf("Removed game: %s", game) reloadLib() http.Redirect(w, r, "/", 302) }