Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Browse ¶
type Browse struct {
// Use this template file instead of the default browse template.
TemplateFile string `json:"template_file,omitempty"`
// contains filtered or unexported fields
}
Browse configures directory browsing.
type FileServer ¶
type FileServer struct {
// The path to the root of the site. Default is `{http.vars.root}` if set,
// or current working directory otherwise.
Root string `json:"root,omitempty"`
// A list of files or folders to hide; the file server will pretend as if
// they don't exist. Accepts globular patterns like "*.hidden" or "/foo/*/bar".
Hide []string `json:"hide,omitempty"`
// The names of files to try as index files if a folder is requested.
IndexNames []string `json:"index_names,omitempty"`
// Enables file listings if a directory was requested and no index
// file is present.
Browse *Browse `json:"browse,omitempty"`
// Use redirects to enforce trailing slashes for directories, or to
// remove trailing slash from URIs for files. Default is true.
CanonicalURIs *bool `json:"canonical_uris,omitempty"`
// If pass-thru mode is enabled and a requested file is not found,
// it will invoke the next handler in the chain instead of returning
// a 404 error. By default, this is false (disabled).
PassThru bool `json:"pass_thru,omitempty"`
}
FileServer implements a static file server responder for Caddy.
func (FileServer) CaddyModule ¶
func (FileServer) CaddyModule() caddy.ModuleInfo
CaddyModule returns the Caddy module information.
func (*FileServer) Provision ¶
func (fsrv *FileServer) Provision(ctx caddy.Context) error
Provision sets up the static files responder.
func (*FileServer) ServeHTTP ¶
func (fsrv *FileServer) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error
type MatchFile ¶
type MatchFile struct {
// The root directory, used for creating absolute
// file paths, and required when working with
// relative paths; if not specified, `{http.vars.root}`
// will be used, if set; otherwise, the current
// directory is assumed. Accepts placeholders.
Root string `json:"root,omitempty"`
// The list of files to try. Each path here is
// considered related to Root. If nil, the request
// URL's path will be assumed. Files and
// directories are treated distinctly, so to match
// a directory, the filepath MUST end in a forward
// slash `/`. To match a regular file, there must
// be no trailing slash. Accepts placeholders.
TryFiles []string `json:"try_files,omitempty"`
// How to choose a file in TryFiles. Can be:
//
// - first_exist
// - smallest_size
// - largest_size
// - most_recently_modified
//
// Default is first_exist.
TryPolicy string `json:"try_policy,omitempty"`
// A list of delimiters to use to split the path in two
// when trying files. If empty, no splitting will
// occur, and the path will be tried as-is. For each
// split value, the left-hand side of the split,
// including the split value, will be the path tried.
// For example, the path `/remote.php/dav/` using the
// split value `.php` would try the file `/remote.php`.
// Each delimiter must appear at the end of a URI path
// component in order to be used as a split delimiter.
SplitPath []string `json:"split_path,omitempty"`
}
MatchFile is an HTTP request matcher that can match requests based upon file existence.
Upon matching, two new placeholders will be made available:
- `{http.matchers.file.relative}` The root-relative path of the file. This is often useful when rewriting requests. - `{http.matchers.file.absolute}` The absolute path of the matched file.
func (MatchFile) CaddyModule ¶
func (MatchFile) CaddyModule() caddy.ModuleInfo
CaddyModule returns the Caddy module information.
func (MatchFile) Match ¶
Match returns true if r matches m. Returns true if a file was matched. If so, two placeholders will be available:
- http.matchers.file.relative
- http.matchers.file.absolute
func (*MatchFile) UnmarshalCaddyfile ¶
UnmarshalCaddyfile sets up the matcher from Caddyfile tokens. Syntax:
file <files...> {
root <path>
try_files <files...>
try_policy first_exist|smallest_size|largest_size|most_recently_modified
}