Skip to content
iamjinleiPublic

About

MemFS that implements http.FileSystem and http.File interface

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Latest commit

 

History

10 Commits

Folders and files

Repository files navigation

Build Status

MemFS

MemFS that implements http.FileSystem and http.File interface for quick mock up an in-memory http server

fs, _ := memfs.New(map[string][]byte{
	"/root/home/foo/1.txt": []byte("@/root/home/foo/1.txt"),
	"/root/home/bar/1.txt": []byte("@/root/home/bar/1.txt"),
	"/root/home/1.txt":     []byte("@/root/home/1.txt"),
	"/root/home/xyz/":      nil,
}, nil)

srv := &http.Server{Addr: ":8080"}
http.Handle("/", http.StripPrefix("/", http.FileServer(fs)))
srv.ListenAndServe()

Check the example folder for a working implementation

go run example/fileserver.go

About

MemFS that implements http.FileSystem and http.File interface

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages