MatchFile is an HTTP request matcher that can match requests based upon file existence. Upon matching, three 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}
| 63 | // Even though file matching may depend on the OS path |
| 64 | // separator, the placeholder values always use /. |
| 65 | type MatchFile struct { |
| 66 | // The file system implementation to use. By default, the |
| 67 | // local disk file system will be used. |
| 68 | FileSystem string `json:"fs,omitempty"` |
| 69 | |
| 70 | // The root directory, used for creating absolute |
| 71 | // file paths, and required when working with |
| 72 | // relative paths; if not specified, `{http.vars.root}` |
| 73 | // will be used, if set; otherwise, the current |
| 74 | // directory is assumed. Accepts placeholders. |
| 75 | Root string `json:"root,omitempty"` |
| 76 | |
| 77 | // The list of files to try. Each path here is |
| 78 | // considered related to Root. If nil, the request |
| 79 | // URL's path will be assumed. Files and |
| 80 | // directories are treated distinctly, so to match |
| 81 | // a directory, the filepath MUST end in a forward |
| 82 | // slash `/`. To match a regular file, there must |
| 83 | // be no trailing slash. Accepts placeholders. If |
| 84 | // the policy is "first_exist", then an error may |
| 85 | // be triggered as a fallback by configuring "=" |
| 86 | // followed by a status code number, |
| 87 | // for example "=404". |
| 88 | TryFiles []string `json:"try_files,omitempty"` |
| 89 | |
| 90 | // How to choose a file in TryFiles. Can be: |
| 91 | // |
| 92 | // - first_exist |
| 93 | // - first_exist_fallback |
| 94 | // - smallest_size |
| 95 | // - largest_size |
| 96 | // - most_recently_modified |
| 97 | // |
| 98 | // Default is first_exist. |
| 99 | TryPolicy string `json:"try_policy,omitempty"` |
| 100 | |
| 101 | // A list of delimiters to use to split the path in two |
| 102 | // when trying files. If empty, no splitting will |
| 103 | // occur, and the path will be tried as-is. For each |
| 104 | // split value, the left-hand side of the split, |
| 105 | // including the split value, will be the path tried. |
| 106 | // For example, the path `/remote.php/dav/` using the |
| 107 | // split value `.php` would try the file `/remote.php`. |
| 108 | // Each delimiter must appear at the end of a URI path |
| 109 | // component in order to be used as a split delimiter. |
| 110 | SplitPath []string `json:"split_path,omitempty"` |
| 111 | |
| 112 | fsmap caddy.FileSystems |
| 113 | |
| 114 | logger *zap.Logger |
| 115 | } |
| 116 | |
| 117 | // CaddyModule returns the Caddy module information. |
| 118 | func (MatchFile) CaddyModule() caddy.ModuleInfo { |
nothing calls this directly
no outgoing calls
no test coverage detected