Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
Prefix = ""
)
Functions ¶
func FileServer ¶ added in v0.5.8
func FileServer(root FileSystem) http.Handler
FileServer is a drop-in replacement for Go's standard http.FileServer which adds support for static resources precompressed with gzip, at the cost of removing the support for directory browsing.
If file filename.ext has a compressed version filename.ext.gz alongside it, if the client indicates that it accepts gzip-compressed data, and if the .gz file can be opened, then the compressed version of the file will be sent to the client. Otherwise the request is passed on to http.ServeContent, and the raw (uncompressed) version is used.
It is up to you to ensure that the compressed and uncompressed versions of files match and have sensible timestamps.
Compressed or not, requests are fulfilled using http.ServeContent, and details like accept ranges and content-type sniffing are handled by that method.
Types ¶
type Dir ¶ added in v0.5.8
type Dir string
Dir is a replacement for the http.Dir type, and implements FileSystem.
type FileSystem ¶ added in v0.5.8
type FileSystem interface { http.FileSystem Exists(string) bool }
FileSystem is a wrapper around the http.FileSystem interface, adding a method to let us check for the existence of files without (attempting to) open them.