@@ -94,7 +94,7 @@ func main() {
9494 w .WriteHeader (http .StatusOK )
9595 })
9696
97- http .ListenAndServe (fmt . Sprintf ( ":8080" ) , nil )
97+ http .ListenAndServe (":8080" , nil )
9898}
9999
100100func errorHandler (path , defaultFormat string ) func (http.ResponseWriter , * http.Request ) {
@@ -149,7 +149,6 @@ func errorHandler(path, defaultFormat string) func(http.ResponseWriter, *http.Re
149149 code = 404
150150 log .Printf ("unexpected error reading return code: %v. Using %v" , err , code )
151151 }
152- w .WriteHeader (code )
153152
154153 if ! strings .HasPrefix (ext , "." ) {
155154 ext = "." + ext
@@ -172,14 +171,16 @@ func errorHandler(path, defaultFormat string) func(http.ResponseWriter, *http.Re
172171 }
173172 defer f .Close ()
174173 log .Printf ("serving custom error response for code %v and format %v from file %v" , code , format , file )
174+ w .WriteHeader (code )
175175 io .Copy (w , f )
176176 return
177177 }
178178 defer f .Close ()
179179 log .Printf ("serving custom error response for code %v and format %v from file %v" , code , format , file )
180+ w .WriteHeader (code )
180181 io .Copy (w , f )
181182
182- duration := time .Now (). Sub (start ).Seconds ()
183+ duration := time .Since (start ).Seconds ()
183184
184185 proto := strconv .Itoa (r .ProtoMajor )
185186 proto = fmt .Sprintf ("%s.%s" , proto , strconv .Itoa (r .ProtoMinor ))
0 commit comments