diff --git a/src/ui/controllers/index.go b/src/ui/controllers/index.go index bb8988596..22cbd4a9b 100644 --- a/src/ui/controllers/index.go +++ b/src/ui/controllers/index.go @@ -14,13 +14,23 @@ package controllers -import "github.com/astaxie/beego" +import ( + "github.com/astaxie/beego" + "github.com/vmware/harbor/src/ui/config" +) // IndexController handles request to / type IndexController struct { beego.Controller } +//Prepare to check if incoming requests should be served +func (ic *IndexController) Prepare() { + if config.WithAdmiral() { + ic.Redirect(config.AdmiralEndpoint(), 302) + } +} + // Get renders the index page func (ic *IndexController) Get() { ic.TplExt = "html" diff --git a/src/ui/router.go b/src/ui/router.go index 24b912b56..22f329ca2 100644 --- a/src/ui/router.go +++ b/src/ui/router.go @@ -30,35 +30,36 @@ func initRouters() { beego.SetStaticPath("/static", "./static") beego.SetStaticPath("/i18n", "./static/i18n") + //Page Controllers: + beego.Router("/", &controllers.IndexController{}) + beego.Router("/sign-in", &controllers.IndexController{}) + beego.Router("/sign-up", &controllers.IndexController{}) + beego.Router("/reset_password", &controllers.IndexController{}) + + beego.Router("/harbor", &controllers.IndexController{}) + + beego.Router("/harbor/sign-in", &controllers.IndexController{}) + beego.Router("/harbor/sign-up", &controllers.IndexController{}) + beego.Router("/harbor/dashboard", &controllers.IndexController{}) + beego.Router("/harbor/projects", &controllers.IndexController{}) + beego.Router("/harbor/projects/:id/repositories", &controllers.IndexController{}) + beego.Router("/harbor/projects/:id/repositories/*", &controllers.IndexController{}) + beego.Router("/harbor/projects/:id/replications", &controllers.IndexController{}) + beego.Router("/harbor/projects/:id/members", &controllers.IndexController{}) + beego.Router("/harbor/projects/:id/logs", &controllers.IndexController{}) + beego.Router("/harbor/tags/:id/*", &controllers.IndexController{}) + + beego.Router("/harbor/users", &controllers.IndexController{}) + beego.Router("/harbor/logs", &controllers.IndexController{}) + beego.Router("/harbor/replications", &controllers.IndexController{}) + beego.Router("/harbor/replications/endpoints", &controllers.IndexController{}) + beego.Router("/harbor/replications/rules", &controllers.IndexController{}) + beego.Router("/harbor/tags", &controllers.IndexController{}) + beego.Router("/harbor/configs", &controllers.IndexController{}) + // standalone if !config.WithAdmiral() { - //Disable page access in integration mode. - //Page Controllers: - beego.Router("/", &controllers.IndexController{}) - beego.Router("/sign-in", &controllers.IndexController{}) - beego.Router("/sign-up", &controllers.IndexController{}) - beego.Router("/reset_password", &controllers.IndexController{}) - - beego.Router("/harbor", &controllers.IndexController{}) - - beego.Router("/harbor/sign-in", &controllers.IndexController{}) - beego.Router("/harbor/sign-up", &controllers.IndexController{}) - beego.Router("/harbor/dashboard", &controllers.IndexController{}) - beego.Router("/harbor/projects", &controllers.IndexController{}) - beego.Router("/harbor/projects/:id/repositories", &controllers.IndexController{}) - beego.Router("/harbor/projects/:id/replications", &controllers.IndexController{}) - beego.Router("/harbor/projects/:id/members", &controllers.IndexController{}) - beego.Router("/harbor/projects/:id/logs", &controllers.IndexController{}) - beego.Router("/harbor/tags/:id/*", &controllers.IndexController{}) - - beego.Router("/harbor/users", &controllers.IndexController{}) - beego.Router("/harbor/logs", &controllers.IndexController{}) - beego.Router("/harbor/replications", &controllers.IndexController{}) - beego.Router("/harbor/replications/endpoints", &controllers.IndexController{}) - beego.Router("/harbor/replications/rules", &controllers.IndexController{}) - beego.Router("/harbor/tags", &controllers.IndexController{}) - beego.Router("/harbor/configs", &controllers.IndexController{}) - + //Controller API: beego.Router("/login", &controllers.CommonController{}, "post:Login") beego.Router("/log_out", &controllers.CommonController{}, "get:LogOut") beego.Router("/reset", &controllers.CommonController{}, "post:ResetPassword")