cleaning up the middleware and adding caching with TTL

This commit is contained in:
Brad Rydzewski
2015-10-13 02:08:08 -07:00
parent 7be93921bd
commit a7a1b1dfb7
14 changed files with 430 additions and 73 deletions

View File

@@ -7,9 +7,10 @@ import (
"github.com/gin-gonic/gin"
"github.com/drone/drone/controller"
"github.com/drone/drone/router/middleware/cache"
"github.com/drone/drone/router/middleware/header"
"github.com/drone/drone/router/middleware/refresh"
"github.com/drone/drone/router/middleware/session"
"github.com/drone/drone/router/middleware/token"
"github.com/drone/drone/static"
"github.com/drone/drone/template"
)
@@ -19,10 +20,13 @@ func Load(middleware ...gin.HandlerFunc) http.Handler {
e.SetHTMLTemplate(template.Load())
e.StaticFS("/static", static.FileSystem())
e.Use(header.SetHeaders())
e.Use(header.NoCache)
e.Use(header.Options)
e.Use(header.Secure)
e.Use(middleware...)
e.Use(session.SetUser())
e.Use(refresh.Refresh)
e.Use(cache.Perms)
e.Use(token.Refresh)
e.GET("/", controller.ShowIndex)
e.GET("/login", controller.ShowLogin)
@@ -58,7 +62,7 @@ func Load(middleware ...gin.HandlerFunc) http.Handler {
user.GET("", controller.GetSelf)
user.GET("/builds", controller.GetFeed)
user.GET("/repos", controller.GetRepos)
user.GET("/repos/remote", controller.GetRemoteRepos)
user.GET("/repos/remote", cache.Repos, controller.GetRemoteRepos)
user.POST("/token", controller.PostToken)
}