aboutsummaryrefslogtreecommitdiff
path: root/cmd/web/download.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/web/download.go')
-rw-r--r--cmd/web/download.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/cmd/web/download.go b/cmd/web/download.go
new file mode 100644
index 0000000..a640ea2
--- /dev/null
+++ b/cmd/web/download.go
@@ -0,0 +1,31 @@
+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
+ }
+
+}
+