MCPcopy
hub / github.com/cortesi/devd / ServeFile

Function ServeFile

fileserver/fileserver_test.go:34–48  ·  view source on GitHub ↗

ServeFile replies to the request with the contents of the named file or directory.

(w http.ResponseWriter, r *http.Request, name string)

Source from the content-addressed store, hash-verified

32
33// ServeFile replies to the request with the contents of the named file or directory.
34func ServeFile(w http.ResponseWriter, r *http.Request, name string) {
35 dir, file := filepath.Split(name)
36 logger := termlog.NewLog()
37 logger.Quiet()
38
39 fs := FileServer{
40 "version",
41 http.Dir(dir),
42 inject.CopyInject{},
43 ricetemp.MustMakeTemplates(rice.MustFindBox("../templates")),
44 []routespec.RouteSpec{},
45 "",
46 }
47 fs.serveFile(logger, w, r, file, false)
48}
49
50func ServeContent(w http.ResponseWriter, req *http.Request, name string, modtime time.Time, content io.ReadSeeker) error {
51 sizeFunc := func() (int64, error) {

Callers 5

TestServeFileFunction · 0.85
TestServeFileContentTypeFunction · 0.85
TestServeFileMimeTypeFunction · 0.85
TestServeFileFromCWDFunction · 0.85

Calls 1

serveFileMethod · 0.95

Tested by

no test coverage detected