You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.3 KiB

  1. # go-bindata-assetfs
  2. Serve embedded files from [jteeuwen/go-bindata](https://github.com/jteeuwen/go-bindata) with `net/http`.
  3. [GoDoc](http://godoc.org/github.com/elazarl/go-bindata-assetfs)
  4. ### Installation
  5. Install with
  6. $ go get github.com/jteeuwen/go-bindata/...
  7. $ go get github.com/elazarl/go-bindata-assetfs/...
  8. ### Creating embedded data
  9. Usage is identical to [jteeuwen/go-bindata](https://github.com/jteeuwen/go-bindata) usage,
  10. instead of running `go-bindata` run `go-bindata-assetfs`.
  11. The tool will create a `bindata_assetfs.go` file, which contains the embedded data.
  12. A typical use case is
  13. $ go-bindata-assetfs data/...
  14. ### Using assetFS in your code
  15. The generated file provides an `assetFS()` function that returns a `http.Filesystem`
  16. wrapping the embedded files. What you usually want to do is:
  17. http.Handle("/", http.FileServer(assetFS()))
  18. This would run an HTTP server serving the embedded files.
  19. ## Without running binary tool
  20. You can always just run the `go-bindata` tool, and then
  21. use
  22. import "github.com/elazarl/go-bindata-assetfs"
  23. ...
  24. http.Handle("/",
  25. http.FileServer(
  26. &assetfs.AssetFS{Asset: Asset, AssetDir: AssetDir, AssetInfo: AssetInfo, Prefix: "data"}))
  27. to serve files embedded from the `data` directory.