statik-file-system.go 313 B

123456789101112131415161718
  1. package utils
  2. import (
  3. "net/http"
  4. "strings"
  5. )
  6. type StatikFileSystem struct {
  7. http.FileSystem
  8. }
  9. func (s *StatikFileSystem) Exists(prefix string, filepath string) bool {
  10. if p := strings.TrimPrefix(filepath, prefix); len(p) < len(filepath) {
  11. _, err := s.Open("/" + p)
  12. return err == nil
  13. }
  14. return false
  15. }