static/wrap_static.go
2025-01-12 04:01:29 -07:00

22 lines
410 B
Go

package static
import (
"fmt"
"net/http"
)
func (s Static) WrapStatic(url string, truefile string) func(w http.ResponseWriter, r *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != url {
fmt.Println("404: " + r.URL.Path)
Err404(w, r)
return
}
f, err := s.FS.ReadFile(s.prefix + truefile)
if err != nil {
Err404(w, r)
return
}
w.Write(f)
}
}