From 682d4c7edab313eb47df1e99db9a158e9b287863 Mon Sep 17 00:00:00 2001 From: Patrick Peng Sun Date: Sat, 20 May 2017 10:26:45 +1000 Subject: [PATCH] remove unused handler and add comments for new upload handler. --- main.go | 7 ++----- server.go | 5 +++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/main.go b/main.go index 7ecc37a..5ff9219 100644 --- a/main.go +++ b/main.go @@ -21,14 +21,11 @@ func main() { //fs := http.FileServer(http.Dir("/mnt/data/workspace/angular.ts/ng2-admin/dist")) fs := http.FileServer(http.Dir("/mnt/data/workspace/angular.ts/wechat/ng2-admin/dist")) - //http.Handle("/test", http.StripPrefix("/test", fs)) http.Handle("/", fs) //setup handler //http.HandleFunc("/", webrootHandler) - //http.HandleFunc("/api", apiV1Main) - http.HandleFunc("/api", uploadHandler) - //http.ListenAndServe("127.0.0.1:65500", nil) - //CreateDefaultMenu() + http.HandleFunc("/api", apiV1Main) + http.HandleFunc("/upload", uploadHandler) http.ListenAndServe(":65500", nil) } diff --git a/server.go b/server.go index 1e6ddc0..2e52d9f 100644 --- a/server.go +++ b/server.go @@ -169,9 +169,10 @@ func logRequestDebug(data []byte, err error) { } } +//save uploaded 'file' into temporary location func uploadHandler(w http.ResponseWriter, r *http.Request) { - r.ParseMultipartForm(32 << 20) - file, handler, err := r.FormFile("file") + r.ParseMultipartForm(32 << 20) //32MB memory + file, handler, err := r.FormFile("file") //form-field 'file' if err != nil { fmt.Println(err) return