From 2ba3fa42cfdb3e9697ee190bd38c1bc0d82da732 Mon Sep 17 00:00:00 2001 From: hoteas Date: Wed, 11 Oct 2017 09:45:22 +0000 Subject: [PATCH] --- application.go | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/application.go b/application.go index 008f1c1..6b7e6b8 100644 --- a/application.go +++ b/application.go @@ -205,13 +205,16 @@ func (this *Application) handler(w http.ResponseWriter, req *http.Request) { }, CacheIns: this.CacheIns, Resp: w, Req: req, Application: this, RouterString: s, Config: this.Config, Db: &this.Db, HandlerStr: req.RequestURI} + //header默认设置 + header := w.Header() //访问拦截true继续false暂停 - connectListenerLen:=len(this.connectListener) - if connectListenerLen!= 0 { + connectListenerLen := len(this.connectListener) + if connectListenerLen != 0 { for i := 0; i < connectListenerLen; i++ { if !this.connectListener[i](&context) { + header.Set("Content-Type", "text/html; charset=utf-8") context.View() return } @@ -225,6 +228,7 @@ func (this *Application) handler(w http.ResponseWriter, req *http.Request) { if this.Router[s[0]] != nil && this.Router[s[0]][s[1]] != nil && this.Router[s[0]][s[1]][s[2]] != nil { //控制层 this.Router[s[0]][s[1]][s[2]](&context) + header.Set("Content-Type", "text/html; charset=utf-8") context.View() return } @@ -257,11 +261,15 @@ func (this *Application) handler(w http.ResponseWriter, req *http.Request) { return } - header := w.Header() - //类型判断并设置Content-Type if strings.Contains(path, ".css") { - header.Set("Content-Type", "text/css") + header.Set("Content-Type", "text/css; charset=utf-8") + //header.Get(Config["sessionName"].(string)) + } + + //类型判断并设置Content-Type + if strings.Contains(path, ".js") { + header.Set("Content-Type", "application/javascript; charset=utf-8") //header.Get(Config["sessionName"].(string)) } header.Set("Cache-Control", "public")