From a8aa0ad9b31f08d477875d9edd36d057ef83da0b Mon Sep 17 00:00:00 2001 From: wy65701436 Date: Tue, 11 Apr 2017 00:05:28 -0700 Subject: [PATCH] add customize 404 --- src/ui/controllers/error.go | 14 ++++++ src/ui/router.go | 3 ++ src/ui/views/404.tpl | 91 +++++++++++++++++++++++++++++++++++++ 3 files changed, 108 insertions(+) create mode 100644 src/ui/controllers/error.go create mode 100644 src/ui/views/404.tpl diff --git a/src/ui/controllers/error.go b/src/ui/controllers/error.go new file mode 100644 index 000000000..e9a99fba4 --- /dev/null +++ b/src/ui/controllers/error.go @@ -0,0 +1,14 @@ +package controllers + +import ( + "github.com/astaxie/beego" +) + +type ErrorController struct { + beego.Controller +} + +func (ec *ErrorController) Error404() { + ec.Data["content"] = "page not found" + ec.TplName = "404.tpl" +} diff --git a/src/ui/router.go b/src/ui/router.go index 0b65b5165..541a526e7 100644 --- a/src/ui/router.go +++ b/src/ui/router.go @@ -107,4 +107,7 @@ func initRouters() { //external service that hosted on harbor process: beego.Router("/service/notifications", &service.NotificationHandler{}) beego.Router("/service/token", &token.Handler{}) + + //Error pages + beego.ErrorController(&controllers.ErrorController{}) } diff --git a/src/ui/views/404.tpl b/src/ui/views/404.tpl new file mode 100644 index 000000000..0b0d96e15 --- /dev/null +++ b/src/ui/views/404.tpl @@ -0,0 +1,91 @@ + + + + +404 - Page Not Found + + + +
+
+
+ 404 + Page Not Found +
+ +
+
+ +