From 3b6f5647b0689abf04be73c3cf00297051753435 Mon Sep 17 00:00:00 2001 From: Mitch Riedstra Date: Thu, 4 Mar 2021 18:50:47 -0500 Subject: Refactor. Pull most of the functions into methods off of an App struct. Kill most global variables. --- cmd/web/delete.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'cmd/web/delete.go') diff --git a/cmd/web/delete.go b/cmd/web/delete.go index 49a1326..7fa003e 100644 --- a/cmd/web/delete.go +++ b/cmd/web/delete.go @@ -5,7 +5,7 @@ import ( "net/http" ) -func gameDelete(w http.ResponseWriter, r *http.Request) { +func (a App) HandleDelete(w http.ResponseWriter, r *http.Request) { if unauthorizedIfNotLocal(w, r) { return } @@ -25,9 +25,9 @@ func gameDelete(w http.ResponseWriter, r *http.Request) { return } - Lib.Lock() - g, ok := Lib.Games[game] - Lib.Unlock() + a.Library.Lock() + g, ok := a.Library.Games[game] + a.Library.Unlock() if !ok { Logger.Printf("Missing: %s", game) http.Error(w, "Game is missing", 404) @@ -42,6 +42,6 @@ func gameDelete(w http.ResponseWriter, r *http.Request) { } Logger.Printf("Removed game: %s", game) - reloadLib() + a.LibraryReload() http.Redirect(w, r, "/", 302) } -- cgit v1.2.3