From 8cfad7ba5bfbae79990adf24c3baa3a224590386 Mon Sep 17 00:00:00 2001 From: Patrick Peng Sun Date: Sat, 20 May 2017 16:06:47 +1000 Subject: [PATCH] added attachment caching path for CRM --- common_test.go | 1 + main.go | 8 ++++++++ server.go | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/common_test.go b/common_test.go index b8b60f2..059eb6f 100644 --- a/common_test.go +++ b/common_test.go @@ -19,6 +19,7 @@ func SetupConfig() { "https://c.hitxy.org.au/", "wechat", "crmwechat.api"} + GlobalPath = PathsConfig{"/tmp"} } func AssertEqual(t *testing.T, a interface{}, b interface{}, message string) { diff --git a/main.go b/main.go index 5ff9219..37dcccb 100644 --- a/main.go +++ b/main.go @@ -5,6 +5,14 @@ import ( "net/http" ) +//PathsConfig all system available pathes +type PathsConfig struct { + CRMAttachment string `json:"crm_attachmeng"` +} + +//GlobalPath all global pathes configurations +var GlobalPath = PathsConfig{"/tmp/"} + func main() { err := readConfig() //wechat API config if err != nil { diff --git a/server.go b/server.go index 2e52d9f..aa63d56 100644 --- a/server.go +++ b/server.go @@ -187,3 +187,7 @@ func uploadHandler(w http.ResponseWriter, r *http.Request) { defer f.Close() io.Copy(f, file) } + +func crmAttachmentHandler(w http.Response, r *http.Request) { + http.ServeFile(w, r) +}