Use strings.Builder in Fingerprint

This commit is contained in:
Adnan Maolood
2020-10-28 15:13:31 -04:00
parent 7f0b1fa8a1
commit 34ae2a9066
3 changed files with 9 additions and 10 deletions

9
fs.go
View File

@@ -5,7 +5,6 @@ import (
"mime"
"os"
"path"
"path/filepath"
)
func init() {
@@ -25,14 +24,14 @@ type fsHandler struct {
}
func (fsh fsHandler) Respond(w *ResponseWriter, r *Request) {
path := path.Clean(r.URL.Path)
f, err := fsh.Open(path)
p := path.Clean(r.URL.Path)
f, err := fsh.Open(p)
if err != nil {
w.WriteStatus(StatusNotFound)
return
}
// Detect mimetype
ext := filepath.Ext(path)
ext := path.Ext(p)
mimetype := mime.TypeByExtension(ext)
w.SetMimetype(mimetype)
// Copy file to response writer
@@ -71,7 +70,7 @@ func ServeFile(w *ResponseWriter, fs FS, name string) {
return
}
// Detect mimetype
ext := filepath.Ext(name)
ext := path.Ext(name)
mimetype := mime.TypeByExtension(ext)
w.SetMimetype(mimetype)
// Copy file to response writer