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

Method serveNotFoundFile

fileserver/fileserver.go:416–439  ·  view source on GitHub ↗

If the next return value is true, the caller should proceed to the next over-ride path if there is one. If the err return value is non-nil, serving should stop.

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

Source from the content-addressed store, hash-verified

414// over-ride path if there is one. If the err return value is non-nil, serving
415// should stop.
416func (fserver *FileServer) serveNotFoundFile(
417 w http.ResponseWriter,
418 r *http.Request,
419 name string,
420) (next bool, err error) {
421 f, err := fserver.Root.Open(name)
422 if err != nil {
423 return true, nil
424 }
425 defer func() { _ = f.Close() }()
426
427 d, err := f.Stat()
428 if err != nil || d.IsDir() {
429 return true, nil
430 }
431
432 // serverContent will check modification time
433 sizeFunc := func() (int64, error) { return d.Size(), nil }
434 err = serveContent(fserver.Inject, w, r, d.Name(), d.ModTime(), sizeFunc, f)
435 if err != nil {
436 return false, fmt.Errorf("Error serving file: %s", err)
437 }
438 return false, nil
439}
440
441// name is '/'-separated, not filepath.Separator.
442func (fserver *FileServer) serveFile(

Callers 1

notFoundMethod · 0.95

Calls 8

serveContentFunction · 0.85
StatMethod · 0.80
IsDirMethod · 0.80
SizeMethod · 0.80
NameMethod · 0.80
ModTimeMethod · 0.80
OpenMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected