Skip to content

Instantly share code, notes, and snippets.

@bliaxiong
Created January 31, 2015 03:15
Show Gist options
  • Save bliaxiong/c91d3ade6428d0549909 to your computer and use it in GitHub Desktop.
Save bliaxiong/c91d3ade6428d0549909 to your computer and use it in GitHub Desktop.
Simple golang server to serve a zip file.
package main
import (
"net/http"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "applicaiton/zip")
w.Header().Set("Content-Disposition", "attachment; filename='file.html.zip'")
http.ServeFile(w, r, "/Users/bxiong/go/src/file_server/file.html.zip")
})
http.ListenAndServe(":8080", nil)
}
@tail-call
Copy link

There is a Typo in Content-Type header. It should be "application/zip" instead of "applicaiton/zip".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment