if to switch to improve readability

This commit is contained in:
Antoni Sawicki 2020-10-26 01:27:21 -07:00
parent 2c2fbd11a6
commit 69efa1fb92
1 changed files with 3 additions and 2 deletions

5
wrp.go
View File

@ -224,9 +224,10 @@ func imgServer(out http.ResponseWriter, req *http.Request) {
if !nodel {
defer delete(img, req.URL.Path)
}
if strings.HasPrefix(req.URL.Path, ".gif") {
switch {
case strings.HasPrefix(req.URL.Path, ".gif"):
out.Header().Set("Content-Type", "image/gif")
} else if strings.HasPrefix(req.URL.Path, ".png") {
case strings.HasPrefix(req.URL.Path, ".png"):
out.Header().Set("Content-Type", "image/png")
}
out.Header().Set("Content-Length", strconv.Itoa(len(imgbuf.Bytes())))