mirror of
https://github.com/tenox7/wrp.git
synced 2024-11-24 22:30:58 +00:00
use HasSuffix to determine content type
This commit is contained in:
parent
9a0e5809c1
commit
3e8f109edd
6
wrp.go
6
wrp.go
@ -537,11 +537,11 @@ func imgServer(w http.ResponseWriter, r *http.Request) {
|
||||
defer delete(img, r.URL.Path)
|
||||
}
|
||||
switch {
|
||||
case strings.HasPrefix(r.URL.Path, ".gif"):
|
||||
case strings.HasSuffix(r.URL.Path, ".gif"):
|
||||
w.Header().Set("Content-Type", "image/gif")
|
||||
case strings.HasPrefix(r.URL.Path, ".png"):
|
||||
case strings.HasSuffix(r.URL.Path, ".png"):
|
||||
w.Header().Set("Content-Type", "image/png")
|
||||
case strings.HasPrefix(r.URL.Path, ".jpg"):
|
||||
case strings.HasSuffix(r.URL.Path, ".jpg"):
|
||||
w.Header().Set("Content-Type", "image/jpeg")
|
||||
}
|
||||
w.Header().Set("Content-Length", strconv.Itoa(len(imgBuf.Bytes())))
|
||||
|
Loading…
Reference in New Issue
Block a user