Giter VIP home page Giter VIP logo

httpfs's Introduction

httpfs

Go Reference

Collection of Go packages for working with the http.FileSystem interface.

Installation

go get github.com/shurcooL/httpfs

Directories

Path Synopsis
filter Package filter offers an http.FileSystem wrapper with the ability to keep or skip files.
html/vfstemplate Package vfstemplate offers html/template helpers that use http.FileSystem.
httputil Package httputil implements HTTP utility functions for http.FileSystem.
path/vfspath Package vfspath implements utility routines for manipulating virtual file system paths.
text/vfstemplate Package vfstemplate offers text/template helpers that use http.FileSystem.
union Package union offers a simple http.FileSystem that can unify multiple filesystems at various mount points.
vfsutil Package vfsutil implements some I/O utility functions for http.FileSystem.

License

httpfs's People

Contributors

casipw avatar dmitshur avatar slimsag avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

httpfs's Issues

filter: Boolean return value for Func is inverse compared to common similar code.

Issue raised by @neelance. He said:

filter.New is a bit strange, I'd expect the bool to be the other way around: true => include
usually all filter functions that I know use true as "keep"

He provided these examples:

I think that's a reasonable suggestion for an improvement. But I don't use filter package much, so if there are strong other opinions, we can punt on this.

vfsutil: ReadDir compatibility issue with statik/fs

Hi Everybody!

I noticed that the vfsutil.ReadDir used by vfstemplate.ParseGlob is incompatible with https://github.com/rakyll/statik binary file embedding tool.

The problem

// ReadDir reads the contents of the directory associated with file and
// returns a slice of FileInfo values in directory order.
func ReadDir(fs http.FileSystem, name string) ([]os.FileInfo, error) {
	f, err := fs.Open(name)
	if err != nil {
		return nil, err
	}
	defer f.Close()
	return f.Readdir(0)
}

Notice the f.Readdir(0). Some other libraries are ignoring the 0 count like rakyll/statik.

Although the file interface allows 0 for specifying the count but it would be better to specify -1 here to be more compatible with other tools.

Relevant documentation can be found here: https://golang.org/pkg/os/#File.Readdir

Summary

f.Readdir(0) should f.Readdir(-1).

The problem occured in the project called statik. Check out their implementation: https://github.com/rakyll/statik/blob/3bac566d30cdbeddef402a80f3d6305860e59f12/fs/fs.go#L190

I will make a pullrequest for them too.

vfsutil: Remove dependency on godoc/vfs

As far as I can tell, the only type used (in non-test code) is the vfs.ReadSeekCloser, an interface which can easily be duplicated to avoid this unnecessary dependency, and reduce the dependency tree when importing the package.

filter: FilesWithExtensions fails to be useable with filter.Keep.

An issue that @VojtechVitek made me aware of is that FilesWithExtensions does not work well with filter.Keep.

When we created it (/cc @slimsag @neelance), we had filter.Skip usage in mind, e.g., to skip .html and .go files (but not folders), one could do:

filter.Skip(filter.FilesWithExtensions(".html", ".go"))

And it'd do what you'd expect.

However, that fails when you try to use filter.FilesWithExtensions with filter.Keep, e.g., to keep only ".xyz" files:

filter.Keep(filter.FilesWithExtensions(".xyz"))

That fails because none of the directories are kept, so / is not included.

Need to think about how to best resolve this. Some options are to do nothing at all, to document this, to remove FilesWithExtensions (or turn it into a documentation example), to change FilesWithExtensions or to change Keep/Skip.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.