Documentation
¶
Index ¶
Constants ¶
View Source
const DirectiveName = "static_site"
View Source
const FlagName = "static-site"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type StaticSite ¶
type StaticSite struct { // A list of files or folders to hide; the file server will pretend as if // they don't exist. Accepts globular patterns like `*.ext` or `/foo/*/bar` // as well as placeholders. Because site roots can be dynamic, this list // uses file system paths, not request paths. To clarify, the base of // relative paths is the current working directory, NOT the site root. // // Entries without a path separator (`/` or `\` depending on OS) will match // any file or directory of that name regardless of its path. To hide only a // specific file with a name that may not be unique, always use a path // separator. For example, to hide all files or folder trees named "hidden", // put "hidden" in the list. To hide only ./hidden, put "./hidden" in the list. // // When possible, all paths are resolved to their absolute form before // comparisons are made. For maximum clarity and explictness, use complete, // absolute paths; or, for greater portability, use relative paths instead. 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"` // Append suffix to request filename if origin name is not exists. SuffixNames []string `json:"suffix_names,omitempty"` // Use redirects to enforce trailing slashes for directories, or to // remove trailing slash from URIs for files. Default is true. // // Canonicalization will not happen if the last element of the request's // path (the filename) is changed in an internal rewrite, to avoid // clobbering the explicit rewrite with implicit behavior. CanonicalURIs *bool `json:"canonical_uris,omitempty"` // Override the status code written when successfully serving a file. // Particularly useful when explicitly serving a file as display for // an error, like a 404 page. A placeholder may be used. By default, // the status code will typically be 200, or 206 for partial content. StatusCode caddyhttp.WeakString `json:"status_code,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"` // contains filtered or unexported fields }
StaticSite implements a static file server responder for Caddy.
func (StaticSite) CaddyModule ¶
func (StaticSite) CaddyModule() caddy.ModuleInfo
CaddyModule returns the Caddy module information.
func (*StaticSite) Provision ¶
func (fsrv *StaticSite) Provision(ctx caddy.Context) error
Provision sets up the static files responder.
func (*StaticSite) ServeHTTP ¶
func (fsrv *StaticSite) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error
Click to show internal directories.
Click to hide internal directories.