Efficient serving of pre-compressed static files.
Go to file
Laurence Withers f08165b0f1 Update README to remove reference to external brotli command
Since we're now using github.com/andybalholm/brotli to natively pack, there's no need to refer
to an external brotli process any more.
2020-02-15 11:23:42 +00:00
cmd Add CLI progress bars to the packer tool 2020-02-15 11:22:24 +00:00
packed Reorganise ready to split into modules 2019-04-12 09:07:17 +01:00
.gitignore Finish up the initial packserver implementation 2019-04-15 14:10:26 +01:00
LICENSE Add MIT licence file 2020-01-15 18:31:11 +00:00
README.md Update README to remove reference to external brotli command 2020-02-15 11:23:42 +00:00
go.mod Moved module to src.lwithers.me.uk 2020-01-15 18:28:43 +00:00
go.sum Moved module to src.lwithers.me.uk 2020-01-15 18:28:43 +00:00
handler.go Moved module to src.lwithers.me.uk 2020-01-15 18:28:43 +00:00

README.md

HTTP resource pack server

A common scenario is that you have a set of static resources that you want to serve up quickly via HTTP (for example: stylesheets, WASM).

This package provides a net/http-compatible http.Handler to do so, with support for:

  • compression
    • gzip
    • brotli
    • does not yet support Transfer-Encoding, only Accept-Encoding/Content-Encoding
  • etags
  • ranges

The workflow is as follows:

  • (optional) build YAML file describing files to serve
  • run htpacker tool to produce a single .htpack file
  • create htpack.Handler pointing at .htpack file

The handler can easily be combined with middleware (http.StripPrefix etc.).

Range handling notes

Too many bugs have been found with range handling and composite ranges, so the handler only accepts a single range within the limits of the file. Anything else will be ignored.

The interaction between range handling and compression also seems a little ill-defined; as we have pre-compressed data, however, we can consistently serve the exact same byte data for compressed files.