This commit is contained in:
hoteas 2018-04-07 16:54:08 +00:00
parent 3488eab401
commit 36dec599a2
2 changed files with 5 additions and 4 deletions

View File

@ -135,7 +135,8 @@ func (this *Application) SetConfig(configPath ...string) {
cmap.JsonToMap(string(btes), &this.Error) cmap.JsonToMap(string(btes), &this.Error)
for k, v := range cmap { for k, v := range cmap {
this.Config.Put(k, v) this.Config.Put(k, v)//程序配置
Config.Put(k,v)//系统配置
} }
} }
//else { //else {
@ -214,7 +215,7 @@ func (this *Application) handler(w http.ResponseWriter, req *http.Request) {
// 如果token存在就判断token是否在Session中有保存 // 如果token存在就判断token是否在Session中有保存
// 如果有取出token并复制给cookie // 如果有取出token并复制给cookie
// 没有保存就生成随机的session // 没有保存就生成随机的session
cookie, err := req.Cookie((this.Config["sessionName"]).(string)) cookie, err := req.Cookie(this.Config.GetString("sessionName"))
sessionId := Md5(strconv.Itoa(Rand(10))) sessionId := Md5(strconv.Itoa(Rand(10)))
token := req.FormValue("token") token := req.FormValue("token")
//isFirst:=false //isFirst:=false
@ -225,7 +226,7 @@ func (this *Application) handler(w http.ResponseWriter, req *http.Request) {
//else{ //else{
// isFirst=true; // isFirst=true;
//} //}
http.SetCookie(w, &http.Cookie{Name: this.Config["sessionName"].(string), Value: sessionId, Path: "/"}) http.SetCookie(w, &http.Cookie{Name: this.Config.GetString("sessionName"), Value: sessionId, Path: "/"})
} else { } else {
sessionId = cookie.Value sessionId = cookie.Value
} }

View File

@ -24,7 +24,7 @@ func(this *Error)SetError(err error,loglevel ...int){
return return
} }
lev:=Config.GetInt("LOG_NIL") lev:=Config.GetInt("logLevel")
if len(loglevel)!=0{ if len(loglevel)!=0{
lev=loglevel[0] lev=loglevel[0]