organize better in sub packages
This commit is contained in:
@@ -1,17 +1,20 @@
|
||||
package errors
|
||||
package utils
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"os"
|
||||
)
|
||||
|
||||
// ToHTTPCode gets the respective HTTP code for an error
|
||||
func ToHTTPCode(err error) int {
|
||||
func ErrorToHTTPCode(err error, gone bool) int {
|
||||
switch {
|
||||
case os.IsPermission(err):
|
||||
return http.StatusForbidden
|
||||
case os.IsNotExist(err):
|
||||
return http.StatusNotFound
|
||||
if !gone {
|
||||
return http.StatusNotFound
|
||||
}
|
||||
|
||||
return http.StatusGone
|
||||
case os.IsExist(err):
|
||||
return http.StatusGone
|
||||
default:
|
||||
@@ -1,4 +1,4 @@
|
||||
package variables
|
||||
package utils
|
||||
|
||||
import "reflect"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package variables
|
||||
package utils
|
||||
|
||||
import (
|
||||
"errors"
|
||||
@@ -1,4 +1,4 @@
|
||||
package variables
|
||||
package utils
|
||||
|
||||
import "testing"
|
||||
|
||||
Reference in New Issue
Block a user