Given a path and a "not found" over-ride specification, return an array of over-ride paths that should be considered for serving, in priority order. We assume that path is a sub-path above a certain root, and we never return paths that would fall outside this. We also sanity check file extensions t
(pth string, spec string)
| 266 | // type matches what we serve. This prevents an over-ride for *.html files from |
| 267 | // serving up data when, say, a missing .png is requested. |
| 268 | func notFoundSearchPaths(pth string, spec string) []string { |
| 269 | var ret []string |
| 270 | if strings.HasPrefix(spec, "/") { |
| 271 | ret = []string{path.Clean(spec)} |
| 272 | } else { |
| 273 | for { |
| 274 | pth = path.Dir(pth) |
| 275 | if pth == "/" { |
| 276 | ret = append(ret, path.Join(pth, spec)) |
| 277 | break |
| 278 | } |
| 279 | ret = append(ret, path.Join(pth, spec)) |
| 280 | } |
| 281 | } |
| 282 | return ret |
| 283 | } |
| 284 | |
| 285 | // Get the media type for an extension, via a MIME lookup, defaulting to |
| 286 | // "text/html". |
no outgoing calls