This commit is contained in:
Steven Zou 2017-08-01 15:49:50 +08:00
parent 373acba9fa
commit e7da22d812
2 changed files with 39 additions and 28 deletions

View File

@ -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"

View File

@ -30,9 +30,6 @@ func initRouters() {
beego.SetStaticPath("/static", "./static")
beego.SetStaticPath("/i18n", "./static/i18n")
// standalone
if !config.WithAdmiral() {
//Disable page access in integration mode.
//Page Controllers:
beego.Router("/", &controllers.IndexController{})
beego.Router("/sign-in", &controllers.IndexController{})
@ -46,6 +43,7 @@ func initRouters() {
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{})
@ -59,6 +57,9 @@ func initRouters() {
beego.Router("/harbor/tags", &controllers.IndexController{})
beego.Router("/harbor/configs", &controllers.IndexController{})
// standalone
if !config.WithAdmiral() {
//Controller API:
beego.Router("/login", &controllers.CommonController{}, "post:Login")
beego.Router("/log_out", &controllers.CommonController{}, "get:LogOut")
beego.Router("/reset", &controllers.CommonController{}, "post:ResetPassword")