|
@@ -1,15 +1,13 @@
|
|
|
package routers
|
|
|
|
|
|
import (
|
|
|
- "encoding/json"
|
|
|
"fmt"
|
|
|
"github.com/astaxie/beego"
|
|
|
"github.com/astaxie/beego/context"
|
|
|
"github.com/astaxie/beego/logs"
|
|
|
- "net/http"
|
|
|
+ "nginx-ui/server/base"
|
|
|
config2 "nginx-ui/server/config"
|
|
|
"nginx-ui/server/middleware"
|
|
|
- "nginx-ui/server/models"
|
|
|
"nginx-ui/server/modules/ldap"
|
|
|
"nginx-ui/server/modules/nginx/nginx_controller"
|
|
|
"nginx-ui/server/modules/oauth2"
|
|
@@ -87,25 +85,8 @@ func init() {
|
|
|
beego.Get("/", func(ctx *context.Context) {
|
|
|
ctx.Redirect(301, webPrefix)
|
|
|
})
|
|
|
- beego.Get(config.ContextPath+"/*", func(ctx *context.Context) {
|
|
|
- ctx.Redirect(301, webPrefix)
|
|
|
- })
|
|
|
|
|
|
- beego.ErrorHandler("404", func(writer http.ResponseWriter, request *http.Request) {
|
|
|
- accept := request.Header.Get("accept")
|
|
|
- logs.Warn("404", accept)
|
|
|
- if strings.Contains(accept, "json") {
|
|
|
- writer.Header().Set("content-type", "application/json")
|
|
|
- writer.WriteHeader(200)
|
|
|
- resp := models.RespData{
|
|
|
- Code: -2,
|
|
|
- Msg: "server error",
|
|
|
- }
|
|
|
- str, _ := json.Marshal(&resp)
|
|
|
- writer.Write(str)
|
|
|
- } else {
|
|
|
- writer.WriteHeader(404)
|
|
|
- writer.Write([]byte(""))
|
|
|
- }
|
|
|
+ beego.ErrorController(&base.ErrorController{
|
|
|
+ WebPath: webPrefix,
|
|
|
})
|
|
|
}
|