kevinburke / go-bindata

A small utility which generates Go code from any file. Useful for embedding binary data in a Go program.
Other
346 stars 28 forks source link

Feature request: Implement net/http.FileSystem #8

Closed glerchundi closed 6 years ago

glerchundi commented 6 years ago

Are you open to receive an implementation for net/http.FileSystem for the generated assets? So that it's possible to use http.FileServer?

kevinburke commented 6 years ago

What would the API look like?

glerchundi commented 6 years ago

The laziest one would be to directly implement FileSystem by providing a func like AssetFS(). But, in case we want to set http headers and ease the job for caching layers maybe in the form of a handler is a better approach?

NewAssetHandler(opts) http.Handler

WDYT?

kevinburke commented 6 years ago

The possibility of more options to configure makes me think that we should show/allow users to configure this themselves ? Alternatively, users can provide their own middleware for caching...

Could we just provide an example of how to use this as a FileSystem?

glerchundi commented 6 years ago

Could we just provide an example of how to use this as a FileSystem?

Let me sketch something next week, will post something here.

kevinburke commented 6 years ago

Have you seen this? Linked from the bottom of the README. https://github.com/elazarl/go-bindata-assetfs