Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/schollz/httpfileserver
module github.com/sjsafranek/httpfileserver

go 1.13
13 changes: 13 additions & 0 deletions httpfileserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down