Swap Bulma for DaisyUI (Tailwind) (#111)
This commit is contained in:
parent
fc5db0e95a
commit
c1e9baabe6
53 changed files with 1124 additions and 632 deletions
|
|
@ -2,31 +2,52 @@ package handlers
|
|||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gorilla/sessions"
|
||||
"github.com/labstack/echo/v4"
|
||||
echomw "github.com/labstack/echo/v4/middleware"
|
||||
"github.com/mikestefanello/pagoda/config"
|
||||
"github.com/mikestefanello/pagoda/pkg/context"
|
||||
"github.com/mikestefanello/pagoda/pkg/middleware"
|
||||
"github.com/mikestefanello/pagoda/pkg/services"
|
||||
files "github.com/mikestefanello/pagoda/public"
|
||||
)
|
||||
|
||||
// BuildRouter builds the router.
|
||||
func BuildRouter(c *services.Container) error {
|
||||
// Static files with proper cache control.
|
||||
// ui.File() should be used in ui components to append a cache key to the URL in order to break cache
|
||||
// after each server restart.
|
||||
c.Web.Group("", middleware.CacheControl(c.Config.Cache.Expiration.StaticFile)).
|
||||
Static(config.StaticPrefix, config.StaticDir)
|
||||
// Force HTTPS, if enabled.
|
||||
if c.Config.HTTP.TLS.Enabled {
|
||||
c.Web.Use(echomw.HTTPSRedirect())
|
||||
}
|
||||
|
||||
// Serve public files with cache control.
|
||||
c.Web.Group("", middleware.CacheControl(c.Config.Cache.Expiration.PublicFile)).
|
||||
Static("files", "public/files")
|
||||
|
||||
// Serve static files.
|
||||
// ui.StaticFile() should be used in ui components to append a cache key to the URL to break cache
|
||||
// after each server reboot.
|
||||
c.Web.Group(
|
||||
"",
|
||||
echomw.GzipWithConfig(echomw.GzipConfig{
|
||||
Skipper: func(c echo.Context) bool {
|
||||
for _, ext := range []string{
|
||||
".js",
|
||||
".css",
|
||||
} {
|
||||
if strings.HasSuffix(c.Request().URL.Path, ext) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
},
|
||||
}),
|
||||
middleware.CacheControl(c.Config.Cache.Expiration.PublicFile),
|
||||
).StaticFS("static", echo.MustSubFS(files.Static, "static"))
|
||||
|
||||
// Non-static file route group.
|
||||
g := c.Web.Group("")
|
||||
|
||||
// Force HTTPS, if enabled.
|
||||
if c.Config.HTTP.TLS.Enabled {
|
||||
g.Use(echomw.HTTPSRedirect())
|
||||
}
|
||||
|
||||
// Create a cookie store for session data.
|
||||
cookieStore := sessions.NewCookieStore([]byte(c.Config.App.EncryptionKey))
|
||||
cookieStore.Options.HttpOnly = true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue