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, )
| 414 | // over-ride path if there is one. If the err return value is non-nil, serving |
| 415 | // should stop. |
| 416 | func (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. |
| 442 | func (fserver *FileServer) serveFile( |