MCPcopy Create free account
hub / github.com/perkeep/perkeep / makeFileServer

Function makeFileServer

pkg/server/ui.go:360–374  ·  view source on GitHub ↗
(sourceRoot string, pathToServe string, expectedContentPath string)

Source from the content-addressed store, hash-verified

358}
359
360func 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.

Callers 2

uiFromConfigFunction · 0.85
makeClosureHandlerFunction · 0.85

Calls 2

StatMethod · 0.65
IsDirMethod · 0.65

Tested by

no test coverage detected