move some stuff

This commit is contained in:
Henrique Dias
2016-10-22 12:07:19 +01:00
parent df888b604a
commit 5fce287cd2
10 changed files with 45 additions and 44 deletions

23
utils/errors/errors.go Normal file
View File

@@ -0,0 +1,23 @@
package errors
import (
"net/http"
"os"
)
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
}
}