diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-02-11 21:50:05 +0300 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-02-11 21:50:05 +0300 |
commit | 609bdfcaeceac3588de625955367476192c411b7 (patch) | |
tree | f32f34cf970043983cf6e615381770b229d288ea | |
parent | fbf2a3f06dea7ac2468c6d027518fc62b642bef0 (diff) |
Make the verify pass
-rw-r--r-- | domain.go | 25 |
1 files changed, 11 insertions, 14 deletions
@@ -63,27 +63,24 @@ func (d *domain) checkPath(w http.ResponseWriter, r *http.Request, path string) return } - // If this file is directory, open the index.html - if fi.IsDir() { - // If the URL doesn't end with /, send location to client - if !strings.HasSuffix(r.URL.Path, "/") { - newURL := *r.URL - newURL.Path += "/" - http.Redirect(w, r, newURL.String(), 302) - return - } - + switch { + // If the URL doesn't end with /, send location to client + case fi.IsDir() && !strings.HasSuffix(r.URL.Path, "/"): + newURL := *r.URL + newURL.Path += "/" + http.Redirect(w, r, newURL.String(), 302) + + // If this is directory, we try the index.html + case fi.IsDir(): fullPath = filepath.Join(fullPath, "index.html") fi, err = os.Lstat(fullPath) if err != nil { return } - } - // We don't allow to open non-regular files - if !fi.Mode().IsRegular() { + // We don't allow to open the regular file + case !fi.Mode().IsRegular(): err = fmt.Errorf("%s: is not a regular file", fullPath) - return } return } |