From 5dcc44a1ca485f30025102e8ee69762ed6a574c0 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Sat, 27 Feb 2016 14:10:06 +0000 Subject: [PATCH] update on #54 --- editor/get.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/editor/get.go b/editor/get.go index cf0f3c79..170d6447 100644 --- a/editor/get.go +++ b/editor/get.go @@ -34,14 +34,20 @@ func GET(w http.ResponseWriter, r *http.Request, c *config.Config, filename stri return http.StatusNotAcceptable, errors.New("File format not supported.") } - // Check if the file exists. If it doesn't, send a "Not Found" message + // Check if the file exists. if _, err := os.Stat(filename); os.IsNotExist(err) { return http.StatusNotFound, nil + } else if os.IsPermission(err) { + return http.StatusForbidden, nil + } else if err != nil { + return http.StatusInternalServerError, err } // Open the file and check if there was some error while opening file, err := ioutil.ReadFile(filename) - if err != nil { + if os.IsPermission(err) { + return http.StatusForbidden, nil + } else if err != nil { return http.StatusInternalServerError, err }