diff --git a/backend/api/api.go b/backend/api/api.go index 83196f6b932..3d592a035c3 100644 --- a/backend/api/api.go +++ b/backend/api/api.go @@ -39,7 +39,10 @@ func (self *HttpServer) ListenAndServe() { self.router = gin.Default() self.router.Use(CacheHeadersMiddleware()) - self.router.Use(self.AuthMiddleware()) + + self.router.Static("/public", "./public") + self.router.Static("/app", "./public/app") + self.router.Static("/img", "./public/img") // register & parse templates templates := template.New("templates") @@ -47,15 +50,14 @@ func (self *HttpServer) ListenAndServe() { templates.ParseFiles("./views/index.html") self.router.SetHTMLTemplate(templates) - // register default route - self.router.GET("/", self.index) for _, fn := range routeHandlers { fn(self) } - self.router.Static("/public", "./public") - self.router.Static("/app", "./public/app") - self.router.Static("/img", "./public/img") + // register default route + self.router.GET("/", self.AuthMiddleware(), self.index) + self.router.GET("/login/*_", self.index) + self.router.GET("/dashboard/*_", self.index) self.router.Run(":" + self.port) } @@ -64,9 +66,17 @@ func (self *HttpServer) index(c *gin.Context) { c.HTML(200, "index.html", &indexViewModel{title: "hello from go"}) } +func (self *HttpServer) login(c *gin.Context) { + c.HTML(200, "login.html", &indexViewModel{title: "hello from go"}) +} + func (self *HttpServer) AuthMiddleware() gin.HandlerFunc { return func(c *gin.Context) { session, _ := sessionStore.Get(c.Request, "grafana-session") + // if session.Values["login"] == nil { + // c.Writer.Header().Set("Location", "/login/login#login") + // c.Abort(302) + // } session.Values["asd"] = 1 session.Save(c.Request, c.Writer) } diff --git a/grafana b/grafana index 8699dec5716..c690d4aae84 160000 --- a/grafana +++ b/grafana @@ -1 +1 @@ -Subproject commit 8699dec57162ed419da47e7206ea58f8ec3250a3 +Subproject commit c690d4aae84fc39d7c4bf9a0a820a71f69059b78 diff --git a/grafana-pro b/grafana-pro index 255abcbd2c7..ffa72bf8aa0 100755 Binary files a/grafana-pro and b/grafana-pro differ diff --git a/views/index.html b/views/index.html index 41689dfab64..b4dcac7cf7a 100644 --- a/views/index.html +++ b/views/index.html @@ -7,11 +7,12 @@ Grafana - + + - - + + @@ -20,7 +21,7 @@ - +