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)