speed + more config
This commit is contained in:
15
src/main.go
15
src/main.go
@@ -3,6 +3,9 @@ package main
|
||||
import (
|
||||
"html/template"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/labstack/echo/v4/middleware"
|
||||
@@ -47,9 +50,21 @@ func main() {
|
||||
|
||||
e.Logger.SetLevel(log.DEBUG)
|
||||
e.Use(middleware.Logger())
|
||||
e.Use(middleware.Gzip())
|
||||
e.Use(middleware.HTTPSRedirect())
|
||||
|
||||
e.GET("/health", healthCheck)
|
||||
|
||||
e.Use(func(next echo.HandlerFunc) echo.HandlerFunc {
|
||||
return func(c echo.Context) error {
|
||||
if strings.HasPrefix(c.Request().URL.Path, "/css/") || strings.HasPrefix(c.Request().URL.Path, "/js/") {
|
||||
c.Response().Header().Set("Cache-Control", "public, max-age=31536000") // 1 year
|
||||
c.Response().Header().Set("Expires", time.Now().AddDate(1, 0, 0).Format(http.TimeFormat))
|
||||
}
|
||||
return next(c)
|
||||
}
|
||||
})
|
||||
|
||||
e.Static("/css", "css")
|
||||
e.Static("/js", "js")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user