zipserver

package module
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 9, 2024 License: ISC Imports: 10 Imported by: 1

Documentation

Overview

Package zipserver provides a helper function to serve static assets over HTTP directly from a ZIP file.

Its main advantage over zip.Reader wrapped with http.FS and http.FileServer is ability to directly serve Deflate-compressed contents insize ZIP archives to clients.

Usage example:

func run(filename string) error {
	zr, err := zip.OpenReader(filename)
	if err != nil {
		return err
	}
	defer zr.Close()
	return http.ListenAndServe("localhost:8000", zipserver.Handler(&zr.Reader))
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handler

func Handler(z *zip.Reader) http.Handler

Handler wraps *zip.Reader, providing HTTP access to its contents. If an incoming HTTP request announces support for compressed content with “Accept-Encoding: deflate” header, and a requested file inside a ZIP archive is compressed with Deflate method, Handler serves such file to the client as a “Content-Encoding: deflate” response.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL