diff --git a/go.mod b/go.mod index d60cda6..f51a4fd 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ -module github.com/schollz/httpfileserver +module github.com/sjsafranek/httpfileserver go 1.13 diff --git a/httpfileserver.go b/httpfileserver.go index 3a06967..e987f09 100644 --- a/httpfileserver.go +++ b/httpfileserver.go @@ -21,6 +21,19 @@ type fileServer struct { optionMaxBytesPerFile int } +// Flush clears all data from cache +func (fs *fileServer) Flush() error { + fs.cache.Range(func(k, v interface{}) bool { + f, ok := v.(file) + if !ok { + return false + } + fs.cache.Delete(k) + return true + }) + return nil +} + // New returns a new file server that can handle requests for // files using an in-memory store with gzipping func New(route, dir string, options ...Option) *fileServer {