Files
PrivateCaptcha/widget/build.go
T
Taras Kushnir 4951055189 Initial commit
2025-05-31 10:56:00 +03:00

25 lines
483 B
Go

package widget
import (
"embed"
"io/fs"
"log/slog"
"net/http"
"github.com/PrivateCaptcha/PrivateCaptcha/pkg/common"
)
//go:embed static
var staticFiles embed.FS
func Static() http.HandlerFunc {
sub, _ := fs.Sub(staticFiles, "static")
srv := http.FileServer(http.FS(sub))
return func(w http.ResponseWriter, r *http.Request) {
slog.DebugContext(r.Context(), "Static request", "path", r.URL.Path)
common.WriteHeaders(w, common.CachedHeaders)
srv.ServeHTTP(w, r)
}
}