organize better in sub packages

This commit is contained in:
Henrique Dias
2016-10-18 21:30:10 +01:00
parent 06c1a412a6
commit f2fbe92591
10 changed files with 47 additions and 35 deletions

View File

@@ -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:

View File

@@ -1,4 +1,4 @@
package variables
package utils
import "reflect"

View File

@@ -1,4 +1,4 @@
package variables
package utils
import (
"errors"

View File

@@ -1,4 +1,4 @@
package variables
package utils
import "testing"