httpembed

package module
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2023 License: ISC Imports: 10 Imported by: 1

README

httpembed

-- import "vimagination.zapto.org/httpembed"

Package httpembed aids with handling compressed 'embed' buffers and FSs, turning them into HTTP Handlers

Usage

var ErrNotFound = errors.New("file not found")
func DecompressFS
func DecompressFS(files fs.FS) (fs.FS, error)

DecompressFS takes a FS with compressed (.gz) files and returns a new FS with those files decompressed and store under the same name with the .gz suffix removed.

The output of this is intended to be use with httpgzip.FileServer.

func HandleBuffer
func HandleBuffer(name string, compressed []byte, size int, lastMod time.Time) http.Handler

HandleBuffer takes filename, a gzip compressed data buffer, its uncompressed size, and a last modified date, and turns it into a handler that will detect whether the client can handle the compressed data and send the data accordingly.

If the uncompressed size is 0, the decompress buffer will be dynamically allocated.

func HandleReader
func HandleReader(name string, r io.Reader, compressedSize, uncompressedSize int, lastMod time.Time) http.Handler

HandleReader takes filename, a gzip compressed data buffer, its compressed and uncompressed size, and a last modified date, and turns it into a handler that will detect whether the client can handle the compressed data and send the data accordingly.

If the either the compressed size or uncompressed size is 0, the buffers will be dynamically allocated.

Documentation

Overview

Package httpembed aids with handling compressed 'embed' buffers and FSs, turning them into HTTP Handlers

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecompressFS added in v1.3.0

func DecompressFS(files fs.FS) (fs.FS, error)

DecompressFS takes a FS with compressed (.gz) files and returns a new FS with those files decompressed and store under the same name with the .gz suffix removed.

The output of this is intended to be use with httpgzip.FileServer.

func HandleBuffer

func HandleBuffer(name string, compressed []byte, size int, lastMod time.Time) http.Handler

HandleBuffer takes filename, a gzip compressed data buffer, its uncompressed size, and a last modified date, and turns it into a handler that will detect whether the client can handle the compressed data and send the data accordingly.

If the uncompressed size is 0, the decompress buffer will be dynamically allocated.

func HandleReader added in v1.2.0

func HandleReader(name string, r io.Reader, compressedSize, uncompressedSize int, lastMod time.Time) http.Handler

HandleReader takes filename, a gzip compressed data buffer, its compressed and uncompressed size, and a last modified date, and turns it into a handler that will detect whether the client can handle the compressed data and send the data accordingly.

If the either the compressed size or uncompressed size is 0, the buffers will be dynamically allocated.

Types

This section is empty.

Jump to

Keyboard shortcuts

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