Commit e77b75ec6c3e2651a1a4a311a193f0b2ef8c2a8e

Authored by Marko Tikvić
1 parent ea858b8a7b
Exists in master and in 1 other branch v2

proper LIKE formating

Showing 2 changed files with 3 additions and 4 deletions   Show diff stats
format_utility.go
... ... @@ -27,7 +27,7 @@ func EqualQuotes(stmt string) string {
27 27  
28 28 func LikeQuotes(stmt string) string {
29 29 if stmt != "" {
30   - stmt = fmt.Sprintf(" LIKE UPPER('%%s%')", stmt)
  30 + stmt = fmt.Sprintf(" LIKE UPPER('%s%s%s')", "%", stmt, "%")
31 31 }
32 32 return stmt
33 33 }
... ...
... ... @@ -49,10 +49,9 @@ func UnauthorizedResponse(w http.ResponseWriter, req *http.Request) {
49 49 })
50 50 }
51 51  
52   -// TODO: Add parameters to enable/disable roles authorization checks
53 52 // TODO: Check for content type
54 53 // Sets common headers and checks for token validity.
55   -func WrapHandler(handlerFunc http.HandlerFunc, needauth bool) http.HandlerFunc {
  54 +func WrapHandler(handlerFunc http.HandlerFunc, auth bool) http.HandlerFunc {
56 55 return func(w http.ResponseWriter, req *http.Request) {
57 56 w.Header().Set("Access-Control-Allow-Origin", "*")
58 57  
... ... @@ -69,7 +68,7 @@ func WrapHandler(handlerFunc http.HandlerFunc, needauth bool) http.HandlerFunc {
69 68 return
70 69 }
71 70  
72   - if needauth {
  71 + if auth {
73 72 token := req.Header.Get("Authorization")
74 73 if _, err := ParseAPIToken(token); err != nil {
75 74 UnauthorizedResponse(w, req)
... ...