From 4b4ea384f8c90564e40be2d90ed474b41b4a0947 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Tikvi=C4=87?= Date: Mon, 28 Nov 2016 10:09:00 +0100 Subject: [PATCH] hmm --- auth_utility.go | 4 ++-- format_utility.go | 5 +++-- http_utility.go | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/auth_utility.go b/auth_utility.go index 1d5448c..ed4b769 100644 --- a/auth_utility.go +++ b/auth_utility.go @@ -27,10 +27,10 @@ type CredentialsStruct struct { Password string `json:"password"` } -func generateSalt() (salt string, error) { +func generateSalt() (salt string, err error) { rawsalt := make([]byte, saltSize) - _, err := rand.Read(rawsalt) + _, err = rand.Read(rawsalt) if err != nil { return "", err } diff --git a/format_utility.go b/format_utility.go index 79611a3..4e8d643 100644 --- a/format_utility.go +++ b/format_utility.go @@ -2,6 +2,7 @@ package restutility import ( "time" + "fmt" ) func UnixToDate(unix int64) time.Time { @@ -19,14 +20,14 @@ func DateToUnix(date interface{}) int64 { func EqualQuotes(stmt string) string { if stmt != "" { - stmt = " = '" + stmt + "'" + stmt = fmt.Sprintf(" = '%s'", stmt) } return stmt } func LikeQuotes(stmt string) string { if stmt != "" { - stmt " LIKE UPPER('%" + stmt + "%')" + stmt = fmt.Sprintf(" LIKE UPPER('%%s%')", stmt) } return stmt } diff --git a/http_utility.go b/http_utility.go index e6aafe7..2c12141 100644 --- a/http_utility.go +++ b/http_utility.go @@ -60,8 +60,8 @@ func WrapHandler(handlerFunc http.HandlerFunc, needauth bool) http.HandlerFunc { "POST, GET, PUT, DELETE, OPTIONS") w.Header().Set("Access-Control-Allow-Headers", - "Accept, Content-Type, Content-Length, " - "Accept-Encoding, X-CSRF-Token, Authorization") + `Accept, Content-Type, Content-Length, + Accept-Encoding, X-CSRF-Token, Authorization`) w.Header().Set("Content-Type", "application/json; charset=utf-8") @@ -72,7 +72,7 @@ func WrapHandler(handlerFunc http.HandlerFunc, needauth bool) http.HandlerFunc { if needauth { token := req.Header.Get("Authorization") if _, err := ParseAPIToken(token); err != nil { - UnathorizedResponse(w, req, http.StatusUnauthorized) + UnauthorizedResponse(w, req) return } } -- 1.8.1.2