aadd first files based on caddy-filemanager

This commit is contained in:
Henrique Dias committed 2017-06-18 13:57:38 +01:00
1 parent f185b9893b
commit 20baeeb41a
28 files changed
+10626 -1

No files matched your search

+24
View File
@@ -0,0 +1,24 @@
package utils
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
}
}