(sourceRoot string, pathToServe string, expectedContentPath string)
| 358 | } |
| 359 | |
| 360 | func makeFileServer(sourceRoot string, pathToServe string, expectedContentPath string) (http.Handler, error) { |
| 361 | fi, err := os.Stat(sourceRoot) |
| 362 | if err != nil { |
| 363 | return nil, err |
| 364 | } |
| 365 | if !fi.IsDir() { |
| 366 | return nil, errors.New("not a directory") |
| 367 | } |
| 368 | dirToServe := filepath.Join(sourceRoot, pathToServe) |
| 369 | _, err = os.Stat(filepath.Join(dirToServe, expectedContentPath)) |
| 370 | if err != nil { |
| 371 | return nil, fmt.Errorf("directory doesn't contain %s; wrong directory?", expectedContentPath) |
| 372 | } |
| 373 | return http.FileServer(http.Dir(dirToServe)), nil |
| 374 | } |
| 375 | |
| 376 | // closureRedirector is a hack to redirect requests for Closure's million *.js files |
| 377 | // to https://closure-library.googlecode.com/git. |
no test coverage detected