hashfs

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2025 License: MIT Imports: 8 Imported by: 0

README

hashfs

Package hashfs provides a hashing enabled http.FileServerFS replacement library.

Documentation

Overview

Package hashfs provides a hashing enabled `http.FileServerFS` replacement library.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileServer

func FileServer(fs fs.FS) http.Handler

FileServer returns a handler that serves HTTP requests with the contents of the file system rooted at root. It will expect the requests to contain hashed paths. Use http.StripPrefix to wrap and remove any prefixes if necessary.

func MaybePath

func MaybePath(fs fs.FS, filename string) (string, error)

MaybePath returns the hashed path of filename. The hash is injected before the extension, or at the end if an extension is not found.

func Path

func Path(fs fs.FS, filename string) string

Path returns the hashed path of filename. It panics if the filename is not found or other errors. Use MaybePath for errors instead of panics.

func Unhashed

func Unhashed(fs fs.FS, urlpath string) (string, error)

Unhashed returns the original unhashed filename from a hashed path. It will ensure the hash matches.

Types

This section is empty.

Jump to

Keyboard shortcuts

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