Skip to content

Commit

Permalink
Redirect to dashboard
Browse files Browse the repository at this point in the history
Negotiate content and redirect to dashboard on root path
  • Loading branch information
Victor Castell committed Dec 17, 2018
1 parent 4811e48 commit 8695242
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions dkron/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ func newCommonDashboardData(a *Agent, nodeName, path string) *commonDashboardDat

// dashboardRoutes registers dashboard specific routes on the gin RouterGroup.
func (a *Agent) DashboardRoutes(r *gin.RouterGroup) {
// If we are visiting from a browser redirect to the dashboard
r.GET("/", func(c *gin.Context) {
switch c.NegotiateFormat(gin.MIMEHTML) {
case gin.MIMEHTML:
c.Redirect(http.StatusMovedPermanently, "/"+dashboardPathPrefix+"/")
default:
c.AbortWithStatus(http.StatusNotFound)
}
})

r.GET("/static/*asset", servePublic)

dashboard := r.Group("/" + dashboardPathPrefix)
Expand Down

0 comments on commit 8695242

Please sign in to comment.