more updates

Former-commit-id: af4aaf07df
This commit is contained in:
Henrique Dias
2017-06-19 18:07:03 +01:00
parent 4829870890
commit 8d4981fcb8
17 changed files with 167 additions and 189 deletions

24
http_utils.go Normal file
View File

@@ -0,0 +1,24 @@
package filemanager
import (
"net/http"
"os"
)
// errorToHTTPCode converts errors to HTTP Status Code.
func errorToHTTPCode(err error, gone bool) int {
switch {
case os.IsPermission(err):
return http.StatusForbidden
case os.IsNotExist(err):
if !gone {
return http.StatusNotFound
}
return http.StatusGone
case os.IsExist(err):
return http.StatusGone
default:
return http.StatusInternalServerError
}
}