feat: add hashfs for static asset cache busting and live clock
- Add assets package with dev/prod build tags - Dev: serve from filesystem with Cache-Control: no-store - Prod: use hashfs for cache-busting URLs - Add LiveClock component to show SSE connection status - Update templates to use StaticPath for asset URLs
This commit is contained in:
@@ -2,8 +2,6 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"io/fs"
|
||||
"net/http"
|
||||
"sync"
|
||||
|
||||
@@ -12,6 +10,7 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
"github.com/starfederation/datastar-go/datastar"
|
||||
|
||||
"github.com/ryanhamamura/games/assets"
|
||||
"github.com/ryanhamamura/games/config"
|
||||
"github.com/ryanhamamura/games/connect4"
|
||||
"github.com/ryanhamamura/games/db/repository"
|
||||
@@ -31,11 +30,9 @@ func SetupRoutes(
|
||||
nc *nats.Conn,
|
||||
store *connect4.Store,
|
||||
snakeStore *snake.SnakeStore,
|
||||
assets embed.FS,
|
||||
) {
|
||||
// Static assets
|
||||
subFS, _ := fs.Sub(assets, "assets")
|
||||
router.Handle("/assets/*", http.StripPrefix("/assets/", http.FileServerFS(subFS)))
|
||||
router.Handle("/assets/*", assets.Handler())
|
||||
|
||||
// Hot-reload for development
|
||||
if config.Global.Environment == config.Dev {
|
||||
|
||||
Reference in New Issue
Block a user