aadd first files based on caddy-filemanager
Former-commit-id: 20baeeb41a
This commit is contained in:
1 parent
f185b9893b
commit
1cea7a383d
28 files changed
+2483
-1
No files matched your search
@@ -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
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user