From 0e935832d3fe474ce699d93789695cb4b89461bf Mon Sep 17 00:00:00 2001 From: hoteas Date: Fri, 13 Oct 2017 09:52:34 +0000 Subject: [PATCH] --- application.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/application.go b/application.go index 7a71646..57526ba 100644 --- a/application.go +++ b/application.go @@ -4,6 +4,7 @@ import ( "bytes" "database/sql" "encoding/json" + "fmt" "io/ioutil" "net/http" "os" @@ -40,7 +41,15 @@ func (this *Application) Run(router Router) { this.CacheIns = CacheIns(&CacheMemory{Map: Map{}, Time: this.Config.GetInt64("cacheShortTime")}) } - //http.HandleFunc("/", this.handler) + //异常处理 + defer func() { + if err := recover(); err != nil { + //e.SetError(errors.New(ObjToStr(err)), LOG_FMT) + fmt.Println(err) + this.Run(router) + } + }() + run(this) } @@ -264,7 +273,6 @@ func (this *Application) handler(w http.ResponseWriter, req *http.Request) { //设置header mimeStr := Substr(path, strings.LastIndex(path, "."), len(path)) - //类型判断并设置Content-Type if value, ok := mimeMaps[mimeStr]; ok { header.Set("Content-Type", value)