packagemiddlewareimport("goku-ce-1.0/dao/cache""github.com/codegangsta/inject""github.com/farseer810/yawf""log""net/http")funcCleanupHandler(contextyawf.Context,log*log.Logger){deferfunc(){iferr:=recover();err!=nil{iflog!=nil{log.Printf("PANIC: %s\n",err)}val:=context.Get(inject.InterfaceOf((*http.ResponseWriter)(nil)))res:=val.Interface().(http.ResponseWriter)res.WriteHeader(http.StatusInternalServerError)res.Write([]byte("500 Internal Server Error"))}conn:=cache.GetConnectionFromContext(context)ifconn!=nil{conn.Close()}}()context.Next()}