package main import ( "net/http" "github.com/gorilla/mux" ) func gameDownloader(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) game := vars["game"] libMu.RLock() g, ok := Lib.Games[game] libMu.RUnlock() if !ok { Logger.Printf("Missing: %s", game) http.Error(w, "Game is missing", 404) return } w.Header().Add("Content-type", "application/tar") err := g.Package(w) if err != nil { Logger.Printf("Error Sending game: %s", err) // Headers already sent, don't bother sending an error } }