| @@ -29,8 +29,9 @@ func SetupConfig() { | |||
| CRMConfig = EspoCRMAPIConfig{ | |||
| "https://c.hitxy.org.au/", | |||
| "wechat", | |||
| "crmwechat.api"} | |||
| GlobalPath = PathsConfig{"/tmp", "/tmp"} | |||
| "crmwechat.api", | |||
| "/tmp/"} | |||
| GlobalPath = PathsConfig{"/tmp"} | |||
| KFUsers.kfRenewList() | |||
| } | |||
| @@ -18,6 +18,8 @@ type EspoCRMAPIConfig struct { | |||
| //access Password | |||
| UserPass string `json:"UserPass"` | |||
| AttachmentCache string `json:"AttachmentCache"` | |||
| } | |||
| //CRMConfig contains secrets that cannot store in source file | |||
| @@ -1,5 +1,6 @@ | |||
| { | |||
| "BaseURL": "https://crm.hitxy.org.au/", | |||
| "UserName": "wechat", | |||
| "UserPass": "crmwechat.api" | |||
| "UserPass": "crmwechat.api", | |||
| "AttachmentCache" : "/tmp/" | |||
| } | |||
| @@ -10,14 +10,12 @@ import ( | |||
| //PathsConfig all system available pathes | |||
| type PathsConfig struct { | |||
| CRMAttachment string `json:"crm_attachment"` | |||
| Angular2App string `json:"angular2_app"` | |||
| Angular2App string `json:"angular2_app"` | |||
| } | |||
| //TODO: setup GlobalPath Config, from reading file | |||
| //GlobalPath all global pathes configurations | |||
| var GlobalPath = PathsConfig{ | |||
| "/tmp/", | |||
| "/mnt/data/workspace/angular.ts/wechat/ng2-admin/dist/"} | |||
| //KFUsers info cache about current customer service | |||
| @@ -217,7 +217,7 @@ func uploadHandler(w http.ResponseWriter, r *http.Request) { | |||
| //in this way, user has no 'direct-access' to the CRM server. | |||
| func crmAttachmentHandler(w http.ResponseWriter, r *http.Request) { | |||
| fileID := getCrmFileID(r.URL.Path) | |||
| saveAs := GlobalPath.CRMAttachment + "crm_attach_" + fileID //add prefix for easy deleting | |||
| saveAs := CRMConfig.AttachmentCache + "crm_attach_" + fileID //add prefix for easy deleting | |||
| if isFileExist(saveAs) { | |||
| http.ServeFile(w, r, saveAs) | |||
| return | |||