MCPcopy
hub / github.com/gin-gonic/gin / FileFromFS

Method FileFromFS

context.go:1285–1293  ·  view source on GitHub ↗

FileFromFS writes the specified file from http.FileSystem into the body stream in an efficient way.

(filepath string, fs http.FileSystem)

Source from the content-addressed store, hash-verified

1283
1284// FileFromFS writes the specified file from http.FileSystem into the body stream in an efficient way.
1285func (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
1295var quoteEscaper = strings.NewReplacer("\\", "\\\\", `"`, "\\\"")
1296

Callers 2

StaticFileFSMethod · 0.80

Calls 1

ServeHTTPMethod · 0.45

Tested by 1