first commit

This commit is contained in:
2026-10-03 10:44:29 +08:00
parent f373cb8d37
commit bcf3d3769c
58 changed files with 4313 additions and 487 deletions
+25
View File
@@ -0,0 +1,25 @@
package auth
import (
"embed"
"io/fs"
"net/http"
)
//go:embed assets
var assetsFS embed.FS
// StaticHandler 以 /static/ 前綴提供 assets 內的靜態檔案
// (Tailwind 建置輸出的 CSS 等),並允許瀏覽器快取。
func StaticHandler() http.Handler {
sub, err := fs.Sub(assetsFS, "assets")
if err != nil {
panic(err) // embed 路徑固定,僅防呆
}
fileServer := http.StripPrefix("/static/", http.FileServerFS(sub))
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// 內容隨執行檔重建,過期重抓即可。
w.Header().Set("Cache-Control", "public, max-age=3600")
fileServer.ServeHTTP(w, r)
})
}