example

command
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2023 License: MIT Imports: 9 Imported by: 0

README

This directory provides an example implementation of hashfs. Run it with go run example.go.

Documentation

Overview

Package example provides an example HTTP server for showing how hashfs is implemented and the results you can inspect.

Simply run with go run example.com and open a browser to localhost:8080.

Implementation of HashFS:

  • Your source files are read via embed.FS.
  • Your static files are provided to hashfs.NewFS.
  • You define a func (see static below) to rewrite your URLs from the original name to the name generated by hashfs based on each file's contents.
  • You modify your your HTML templates to use the defined func for each static file. see {{static ...}} in website/templates/index.html.
  • When your HTML templates are parsed, the defined func rewrites the URLs to each static file to include a hash of each file's contents.

Jump to

Keyboard shortcuts

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