Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions images/custom-error-pages/rootfs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func main() {
w.WriteHeader(http.StatusOK)
})

http.ListenAndServe(fmt.Sprintf(":8080"), nil)
http.ListenAndServe(":8080", nil)
}

func errorHandler(path, defaultFormat string) func(http.ResponseWriter, *http.Request) {
Expand Down Expand Up @@ -149,7 +149,6 @@ func errorHandler(path, defaultFormat string) func(http.ResponseWriter, *http.Re
code = 404
log.Printf("unexpected error reading return code: %v. Using %v", err, code)
}
w.WriteHeader(code)

if !strings.HasPrefix(ext, ".") {
ext = "." + ext
Expand All @@ -172,14 +171,16 @@ func errorHandler(path, defaultFormat string) func(http.ResponseWriter, *http.Re
}
defer f.Close()
log.Printf("serving custom error response for code %v and format %v from file %v", code, format, file)
w.WriteHeader(code)
io.Copy(w, f)
return
}
defer f.Close()
log.Printf("serving custom error response for code %v and format %v from file %v", code, format, file)
w.WriteHeader(code)
io.Copy(w, f)

duration := time.Now().Sub(start).Seconds()
duration := time.Since(start).Seconds()

proto := strconv.Itoa(r.ProtoMajor)
proto = fmt.Sprintf("%s.%s", proto, strconv.Itoa(r.ProtoMinor))
Expand Down