23 lines
410 B
Go
23 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)
|
||
|
}
|
||
|
}
|