mirror of
https://github.com/mindoc-org/mindoc.git
synced 2025-09-18 17:48:00 +08:00
fix:修复beego使用file储存session时存在的路径BUG
This commit is contained in:
@@ -12,7 +12,6 @@ import (
|
||||
"time"
|
||||
|
||||
"encoding/json"
|
||||
|
||||
"github.com/astaxie/beego"
|
||||
beegoCache "github.com/astaxie/beego/cache"
|
||||
_ "github.com/astaxie/beego/cache/memcache"
|
||||
@@ -26,6 +25,8 @@ import (
|
||||
"github.com/lifei6671/mindoc/utils/filetil"
|
||||
"github.com/astaxie/beego/cache/redis"
|
||||
"github.com/howeyc/fsnotify"
|
||||
"net/http"
|
||||
"bytes"
|
||||
)
|
||||
|
||||
// RegisterDataBase 注册数据库
|
||||
@@ -448,6 +449,35 @@ func RegisterAutoLoadConfig() {
|
||||
}
|
||||
}
|
||||
}
|
||||
//注册错误处理方法.
|
||||
func RegisterError() {
|
||||
beego.ErrorHandler("404", func(writer http.ResponseWriter, request *http.Request) {
|
||||
var buf bytes.Buffer
|
||||
|
||||
data :=make(map[string]interface{})
|
||||
data["ErrorCode"] = 404
|
||||
data["ErrorMessage"] = "页面未找到或已删除"
|
||||
|
||||
if err := beego.ExecuteViewPathTemplate(&buf,"errors/error.tpl",beego.BConfig.WebConfig.ViewsPath,data);err == nil {
|
||||
fmt.Fprint(writer,buf.String())
|
||||
} else {
|
||||
fmt.Fprint(writer,data["ErrorMessage"])
|
||||
}
|
||||
})
|
||||
beego.ErrorHandler("401", func(writer http.ResponseWriter, request *http.Request) {
|
||||
var buf bytes.Buffer
|
||||
|
||||
data :=make(map[string]interface{})
|
||||
data["ErrorCode"] = 401
|
||||
data["ErrorMessage"] = "请与 Web 服务器的管理员联系,以确认您是否具有访问所请求资源的权限。"
|
||||
|
||||
if err := beego.ExecuteViewPathTemplate(&buf,"errors/error.tpl",beego.BConfig.WebConfig.ViewsPath,data);err == nil {
|
||||
fmt.Fprint(writer,buf.String())
|
||||
} else {
|
||||
fmt.Fprint(writer,data["ErrorMessage"])
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
||||
|
Reference in New Issue
Block a user