FileFromFS writes the specified file from http.FileSystem into the body stream in an efficient way.
(filepath string, fs http.FileSystem)
| 1283 | |
| 1284 | // FileFromFS writes the specified file from http.FileSystem into the body stream in an efficient way. |
| 1285 | func (c *Context) FileFromFS(filepath string, fs http.FileSystem) { |
| 1286 | defer func(old string) { |
| 1287 | c.Request.URL.Path = old |
| 1288 | }(c.Request.URL.Path) |
| 1289 | |
| 1290 | c.Request.URL.Path = filepath |
| 1291 | |
| 1292 | http.FileServer(fs).ServeHTTP(c.Writer, c.Request) |
| 1293 | } |
| 1294 | |
| 1295 | var quoteEscaper = strings.NewReplacer("\\", "\\\\", `"`, "\\\"") |
| 1296 |