Please read the previous File Server's sections first and read the Introduction to HTTP/2 by Google LLC to learn about the benefits of using HTTP/2.
DirOptions
contains the PushTargets
and PushTargetsRegexp
fields to enable and customize automatic push assets (css, javascript, images) of Index pages.PushTargets
field is a map of filenames to be served without additional client's requests (HTTP/2 Push) when a specific request relative path hits an Index.PushTargetsRegexp
field can be used instead (recommended), to automatically serve common assets based on a regular expression:Theiris.MatchCommonAssets
is just a regular expression which matches javascript, css, ico, png, ttf, svg, webp and gif file types.
http.FileServer
to pass into Party.HandleDir
:main.go
file and copy-paste the following code:go build
or go run .