簡単なダウンローダのような物を作ろうとしてすんなり調べて出て来なかったのでそのメモ
package main
import (
"io/ioutil"
"net/http"
)
func zipDownload(w http.ResponseWriter, r *http.Request) {
file, err := ioutil.ReadFile("test.zip")
if err != nil {
fmt.Println(err)
return
}
w.Header().Set("Content-Type", "application/zip")
w.WriteHeader(http.StatusOK)
w.Write(file)
}
func main() {
http.HandleFunc("/", zipDownload)
http.ListenAndServe(":8080", nil)
}