Skip to content

MemFS that implements http.FileSystem and http.File interface

License

Notifications You must be signed in to change notification settings

iamjinlei/memfs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages