Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( DefaultNotFoundHandler = http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { http.Error(w, "Not Found", http.StatusNotFound) }) DefaultForbiddenHandler = http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { http.Error(w, "Forbidden", http.StatusForbidden) }) DefaultInternalServerErrorHandler = http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { http.Error(w, "Internal Server Error", http.StatusInternalServerError) }) )
Default file handlers in case of errors.
Functions ¶
This section is empty.
Types ¶
type MD5Hasher ¶
type MD5Hasher struct {
HashLength int
}
MD5Hasher uses MD5 sum to compute a file hash.
type Options ¶
type Options struct { // If Hasher is not nil, it will be used to compute a file hash. Hasher Hasher // Do not hash file paths if the request contains query parameters. // It may be used if other tools construct a request with predefined // bust parameter. NoHashQueryStrings bool // Redirect trailing slash of HTTP requests. RedirectTrailingSlash bool // IndexPage is a filename that will be used to render an index page // for a directory. IndexPage string // AltDir is a directory path to look for files before the // initialized directory. AltDir string // Filesystem is optional and is used for opening files. In case of // nil, os.Open will be used to open files. Filesystem http.FileSystem // Filenames are used to find corresponding files with hashes in them // by just iterating through them instead doing filesystem operations. Filenames []string // NotFoundHandler is used when no file can be found. NotFoundHandler http.Handler // ForbiddenHandler is used when permissions to open file are insufficient. ForbiddenHandler http.Handler // InternalServerErrorHandler is used when an unexpected error occurs. InternalServerErrorHandler http.Handler }
Options contains parameters for file server configuration.
type Server ¶
type Server struct { Options // contains filtered or unexported fields }
Server is a HTTP Handler tha serves static files from local filesystem.
func (*Server) HashedPath ¶
HashedPath returns a URL path with hash injected into the filename.
Click to show internal directories.
Click to hide internal directories.