From e77b75ec6c3e2651a1a4a311a193f0b2ef8c2a8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Tikvi=C4=87?= Date: Mon, 28 Nov 2016 11:42:17 +0100 Subject: [PATCH] proper LIKE formating --- format_utility.go | 2 +- http_utility.go | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/format_utility.go b/format_utility.go index e3edd0a..4d93975 100644 --- a/format_utility.go +++ b/format_utility.go @@ -27,7 +27,7 @@ func EqualQuotes(stmt string) string { func LikeQuotes(stmt string) string { if stmt != "" { - stmt = fmt.Sprintf(" LIKE UPPER('%%s%')", stmt) + stmt = fmt.Sprintf(" LIKE UPPER('%s%s%s')", "%", stmt, "%") } return stmt } diff --git a/http_utility.go b/http_utility.go index 5c26b5c..55065aa 100644 --- a/http_utility.go +++ b/http_utility.go @@ -49,10 +49,9 @@ func UnauthorizedResponse(w http.ResponseWriter, req *http.Request) { }) } -// TODO: Add parameters to enable/disable roles authorization checks // TODO: Check for content type // Sets common headers and checks for token validity. -func WrapHandler(handlerFunc http.HandlerFunc, needauth bool) http.HandlerFunc { +func WrapHandler(handlerFunc http.HandlerFunc, auth bool) http.HandlerFunc { return func(w http.ResponseWriter, req *http.Request) { w.Header().Set("Access-Control-Allow-Origin", "*") @@ -69,7 +68,7 @@ func WrapHandler(handlerFunc http.HandlerFunc, needauth bool) http.HandlerFunc { return } - if needauth { + if auth { token := req.Header.Get("Authorization") if _, err := ParseAPIToken(token); err != nil { UnauthorizedResponse(w, req) -- 1.8.1.2