Documentation ¶
Overview ¶
Package that host the content of a zip via Google net/http.
Example:
package main import ( "fmt" "log" "net/http" "github.com/cjtoolkit/zipfs" ) func main() { // Init ZipFS, if the zip file does not exist it will fallback to embedded zip file within application, if that // also does not exist, it will panic. fs := zipfs.InitZipFs("asset.zip") fmt.Println("Running ZipFS via http server on port 8080.") log.Print(http.ListenAndServe(":8080", http.FileServer(fs))) }
To embed zip to the application, first create a zip file with your preferred achiever with compression disabled. Than append the content of the zip to the compiled application. You can use this simple shell command to append.
$ cat asset.zip >> application
Index ¶
- func GetEmbeddedZip() (*zip.Reader, io.ReaderAt, error)
- func InitZipFs(zipFileName string) http.FileSystem
- func InitZipFsFromHttpFile(f http.File) http.FileSystem
- func Must(f http.File, err error) http.File
- func NewZipFS(z *zip.Reader) http.FileSystem
- func NewZipFSWithReaderAt(z *zip.Reader, readerAt io.ReaderAt) http.FileSystem
- func Prefix(prefix string, fileSystem http.FileSystem) http.FileSystem
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetEmbeddedZip ¶
Tries to get the zip archive, that is embedded inside the running application.
func InitZipFs ¶
func InitZipFs(zipFileName string) http.FileSystem
Initialise ZipFS based on given zip file name. If the file does not exist, it will try to get the zip file that is embedded in the application itself. If the application also does not have zip embedded it will panic.
func InitZipFsFromHttpFile ¶
func InitZipFsFromHttpFile(f http.File) http.FileSystem
Init Zip FS from HTTP File, must be uncompressed. Does not support compressed files!
func NewZipFS ¶
func NewZipFS(z *zip.Reader) http.FileSystem
Create Zip File System, just from the zip reader, with seek disabled.
func NewZipFSWithReaderAt ¶
Create Zip File System, from the zip reader and readerAt. If readerAt is nil, than seeking will be disabled.
func Prefix ¶
func Prefix(prefix string, fileSystem http.FileSystem) http.FileSystem
Add prefix to name
Types ¶
This section is empty.