Open platform to collect and prioritize feedback
cache bundles for one year
goenningb835f11ebc94
diff --git a/app/cache.go b/app/cache.gonew file mode 100644index 000000000..5d28e3d75--- /dev/null+++ b/app/cache.go@@ -0,0 +1,11 @@+package app++// OneYearCache adds Cache-Control header for one year+func OneYearCache() MiddlewareFunc {+ return func(next HandlerFunc) HandlerFunc {+ return func(c Context) error {+ c.Response().Header().Add("Cache-Control", "public, max-age=30672000")+ return next(c)+ }+ }+}diff --git a/router.go b/router.goindex 7938128fa..ab5bc8dc2 100644--- a/router.go+++ b/router.go@@ -93,15 +93,18 @@ func GetMainEngine(ctx *WechyServices) *echo.Echo {router.Use(middleware.Gzip())router.Static("/favicon.ico", "favicon.ico")- router.Static("/assets", "dist")- hostChecker := identity.HostChecker(env.MustGet("AUTH_ENDPOINT"))- authGroup := group(router, "", hostChecker)+ assetsGroup := group(router, "/assets", app.OneYearCache()){- get(authGroup, "/oauth/facebook", identity.OAuth(ctx.OAuth, ctx.User).Login(identity.OAuthFacebookProvider))- get(authGroup, "/oauth/facebook/callback", identity.OAuth(ctx.OAuth, ctx.User).Callback(identity.OAuthFacebookProvider))- get(authGroup, "/oauth/google", identity.OAuth(ctx.OAuth, ctx.User).Login(identity.OAuthGoogleProvider))- get(authGroup, "/oauth/google/callback", identity.OAuth(ctx.OAuth, ctx.User).Callback(identity.OAuthGoogleProvider))+ assetsGroup.Static("/", "dist")+ }++ authGroup := group(router, "/oauth", identity.HostChecker(env.MustGet("AUTH_ENDPOINT")))+ {+ get(authGroup, "/facebook", identity.OAuth(ctx.OAuth, ctx.User).Login(identity.OAuthFacebookProvider))+ get(authGroup, "/facebook/callback", identity.OAuth(ctx.OAuth, ctx.User).Callback(identity.OAuthFacebookProvider))+ get(authGroup, "/google", identity.OAuth(ctx.OAuth, ctx.User).Login(identity.OAuthGoogleProvider))+ get(authGroup, "/google/callback", identity.OAuth(ctx.OAuth, ctx.User).Callback(identity.OAuthGoogleProvider))}appGroup := group(router, "")