Skip to content
Myr

Close files opened in static file handler (#2118)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* Close files opened in static file handler * Do not use defer

authored by Shamus Taylor · committed by thinkerou · parent 517eacb · Browse files · 1 file+3 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+3 added−1 removed

  • other:+3 added−1 removed

1 file+3 added−1 removed

modified:routergroup.go+3 added-1 removed
191 unmodified lines
192 }193194 file := c.Param("filepath")195 // Check if file exists and/or if we have permission to access it196 if _, err := fs.Open(file); err != nil {196 f, err := fs.Open(file)197 if err != nil {198 c.Writer.WriteHeader(http.StatusNotFound)199 c.handlers = group.engine.noRoute200 // Reset index201 c.index = -1202 return203 }204 f.Close()205206 fileServer.ServeHTTP(c.Writer, c.Request)207 }208}
22 unmodified lines