Implementation of io/fs.FS that appends SHA256 hashes to filenames to allow for aggressive HTTP caching.

Related tags

hashfs
Overview

hashfs

Implementation of io/fs.FS that appends SHA256 hashes to filenames to allow for aggressive HTTP caching.

For example, given a file path of /scripts/main.js, the hashfs.FS filesystem will provide the server with a hashname of /scripts/main-b633a..d628.js. Note the hash is truncated for brevity. When this file path is requested by the client, the server can verify the hash and return the contents with an aggressive Cache-Control header. The client will cache this file for up to a year and does not need to re-reqeust it in the future.

Note that this library requires Go 1.16 or higher.

Usage

To use hashfs, first wrap your embed.FS in a hashfs.FS filesystem:

//go:embed scripts stylesheets images
var embedFS embed.FS

var fsys = hashfs.NewFS(embedFS)

Then attach a hashfs.FileServer() to your router:

http.Handle("/assets", http.StripPrefix("/assets", hashfs.FileServer(fsys)))

Next, your html templating library can obtain the hashname of your file using the hashfs.FS.HashName() method:

func renderHTML(w io.Writer) {
	fmt.Fprintf(w, ``)
	fmt.Fprintf(w, `
							
							
		
		
		
																											
                 
Issues
Releases(v0.1.0)
Owner
Ben Johnson
Ben Johnson
crowdsec 3.7k Sep 11, 2021
:key: Idiotproof golang password validation library inspired by Python's passlib

passlib for go Python's passlib is quite an amazing library. I'm not sure there's a password library in existence with more thought put into it, or wi

Hugo Landau 250 Aug 19, 2021
Obfuscate Go code by wrapping the Go toolchain

Obfuscate Go code by wrapping the Go toolchain.

null 1.1k Sep 11, 2021
SourcePoint is a C2 profile generator for Cobalt Strike command and control servers designed to ensure evasion.

SourcePoint SourcePoint is a polymorphic C2 profile generator for Cobalt Strike C2s, written in Go. SourcePoint allows unique C2 profiles to be genera

Tylous 383 Sep 5, 2021
Implementation of polynomial KZG proofs and 257-ary verkle trie

257-ary verkle trie Disclaimer: the code in this package is experimental. It can only be used in research and is not suitable for use in production. T

Evaldas Drasutis 3 Sep 6, 2021
HTTP middleware for Go that facilitates some quick security wins.

Secure Secure is an HTTP middleware for Go that facilitates some quick security wins. It's a standard net/http Handler, and can be used with many fram

Cory Jacobsen 1.8k Sep 8, 2021
Scan and analyze OSS dependencies and licenses from compiled Go binaries

golicense - Go Binary OSS License Scanner golicense is a tool that scans compiled Go binaries and can output all the dependencies, their versions, and

Mitchell Hashimoto 602 Sep 14, 2021
go实现iOS重签名模块(iOS超级签名、蒲公英ios内测分发原理)

这是什么 一个用go实现的iOS重签名模块,即市面上的iOS超级签名、蒲公英ios内测分发原理 使用本模块可以进行基本的IPA安装包重签名分发 实现功能:苹果开发者账号管理、IPA安装包管理 前提 1.生成ios.csr和ios.key文件 openssl genrsa -out

寻寻觅觅 247 Sep 11, 2021
DockerSlim (docker-slim): Don't change anything in your Docker container image and minify it by up to 30x (and for compiled languages even more) making it secure too! (free and open source)

Minify and Secure Docker containers (free and open source!) Don't change anything in your Docker container image and minify it by up to 30x making it

docker-slim 10.6k Sep 13, 2021
A convenience library for generating, comparing and inspecting password hashes using the scrypt KDF in Go 🔑

simple-scrypt simple-scrypt provides a convenience wrapper around Go's existing scrypt package that makes it easier to securely derive strong keys ("h

Matt Silverlock 172 Jul 12, 2021
Custom GPG pinentry program for macOS that allows using Touch ID for fetching the password from the macOS keychain.

pinentry-touchid Custom GPG pinentry program for macOS that allows using Touch ID for fetching the password from the macOS keychain. Macbook Pro devic

Jorge Luis Betancourt 18 Sep 13, 2021
Pure Go implementation of the NaCL set of API's

go-nacl This is a pure Go implementation of the API's available in NaCL: https://nacl.cr.yp.to. Compared with the implementation in golang.org/x/crypt

Kevin Burke 509 Sep 8, 2021
:lock: acmetool, an automatic certificate acquisition tool for ACME (Let's Encrypt)

acmetool is an easy-to-use command line tool for automatically acquiring certificates from ACME servers (such as Let's Encrypt). Designed to flexibly

Hugo Landau 1.9k Sep 5, 2021
Automatic HTTPS for any Go program: fully-managed TLS certificate issuance and renewal

Easy and Powerful TLS Automation The same library used by the Caddy Web Server Caddy's automagic TLS features—now for your own Go programs—in one powe

Caddy 3.7k Sep 13, 2021
A rest application to update firewalld rules on a linux server

Firewalld-rest A REST application to dynamically update firewalld rules on a linux server. Firewalld is a firewall management tool for Linux operating

Prashant Gupta 307 Aug 22, 2021
Ah shhgit! Find secrets in your code. Secrets detection for your GitHub, GitLab and Bitbucket repositories: www.shhgit.com

shhgit helps secure forward-thinking development, operations, and security teams by finding secrets across their code before it leads to a security br

Paul 3.3k Sep 12, 2021
Official library of StackPulse steps

StackPulse Steps This repository is the official library of StackPulse steps. StackPulse steps are containerized applications that can be composed tog

StackPulse 14 Jun 14, 2021
An easy-to-use SHA-1 hash-cracker written in Golang.

wrench - An easy-to-use SHA-1 hash-cracker. Wrench is an SHA-1 hash-cracker that relies on wordlists for comparing hashes, and cracking them. Before W

null 4 Aug 29, 2021