Go lang zip http.FileSystem
$ go get github.com/gnue/httpfs/zipfs
import "github.com/gnue/httpfs/zipfs"
package main
import (
"github.com/gnue/httpfs/zipfs"
"log"
"net/http"
"os"
)
func main() {
b, err := os.ReadFile("public.zip")
if err != nil {
log.Fatal(err)
}
fs, err := zipfs.New(b, &zipfs.Options{Prefix: "public"})
if err != nil {
log.Fatal(err)
}
http.Handle("/", http.FileServer(fs))
http.ListenAndServe(":8080", nil)
}
Simple zip webserver(use New)
package main
import (
"github.com/gnue/httpfs/zipfs"
"log"
"net/http"
)
func main() {
fs, err := zipfs.Open("public.zip", &zipfs.Options{Prefix: "public"})
if err != nil {
log.Fatal(err)
}
defer fs.Close()
http.Handle("/", http.FileServer(fs))
http.ListenAndServe(":8080", nil)
}
Simple zip webserver(use Open)