ServeFile replies to the request with the contents of the named file or directory.
(w http.ResponseWriter, r *http.Request, name string)
| 32 | |
| 33 | // ServeFile replies to the request with the contents of the named file or directory. |
| 34 | func 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 | |
| 50 | func ServeContent(w http.ResponseWriter, req *http.Request, name string, modtime time.Time, content io.ReadSeeker) error { |
| 51 | sizeFunc := func() (int64, error) { |
no test coverage detected