diff --git a/admin/admin.go b/admin/admin.go index 268335f..e3fd616 100644 --- a/admin/admin.go +++ b/admin/admin.go @@ -273,11 +273,10 @@ func apiListImages(next http.Handler, uploads string, uploadType string, udb aut } } } - w.WriteHeader(422) - next.ServeHTTP(w, req) - return + w.WriteHeader(422) + next.ServeHTTP(w, req) + return } - return http.HandlerFunc(handlerFunc) } @@ -285,7 +284,7 @@ func apiListImages(next http.Handler, uploads string, uploadType string, udb aut func apiDeleteImage(next http.Handler, uploads string, uploadType string, udb auth.UserStore, dbAdapter mongodb.DbAdapter) http.Handler { handlerFunc := func(w http.ResponseWriter, req *http.Request) { // put the path together -urlParams := req.Context().Value("params").(map[string]string) + urlParams := req.Context().Value("params").(map[string]string) tableName := urlParams["table"] tableKey := models.TableKey{ Name: tableName, @@ -308,20 +307,20 @@ urlParams := req.Context().Value("params").(map[string]string) if ok { if dbAdapter.CheckTable(tableKey) { - // if the file exists, delete it and return 201 - filename := urlParams["file"] - fullPath := filepath.Join(uploads, tableName, uploadType, filename) - s, err := os.Stat(fullPath) - if err == nil && !s.IsDir() { - err = os.Remove(fullPath) - if err == nil { - w.WriteHeader(201) - next.ServeHTTP(w, req) - return - } - } - } - } + // if the file exists, delete it and return 201 + filename := urlParams["file"] + fullPath := filepath.Join(uploads, tableName, uploadType, filename) + s, err := os.Stat(fullPath) + if err == nil && !s.IsDir() { + err = os.Remove(fullPath) + if err == nil { + w.WriteHeader(201) + next.ServeHTTP(w, req) + return + } + } + } + } } // otherwise, return an error w.WriteHeader(500) diff --git a/gametable/server.go b/gametable/server.go index 1907be5..fc6f7d3 100644 --- a/gametable/server.go +++ b/gametable/server.go @@ -172,7 +172,7 @@ func (self *GameTableServer) publish(msg []byte) { fmt.Println(err.Error()) return } - + self.publishLimiter.Wait(context.Background()) for s, k := range self.subscribers {