@@ -6,6 +6,8 @@ import "fmt"
6
6
import "io"
7
7
import "net/http"
8
8
import "os"
9
+ <% # LATER : add it only when there is at least one parameter of boolean type - %>
10
+ import "strconv"
9
11
import "github.com/go-chi/chi"
10
12
import "github.com/jmoiron/sqlx"
11
13
@@ -175,6 +177,15 @@ endpoints.forEach(function(endpoint) {
175
177
})
176
178
})
177
179
- %>
180
+ <% # LATER : add it only when there is at least one parameter of boolean type - %>
181
+ func parseBoolean(value string) bool {
182
+ boolValue, err := strconv.ParseBool(value)
183
+ if err != nil {
184
+ boolValue = false
185
+ }
186
+ return boolValue
187
+ }
188
+
178
189
func registerRoutes(r chi.Router, db *sqlx.DB) {
179
190
<%
180
191
endpoints .forEach (function (endpoint ) {
@@ -219,7 +230,7 @@ endpoints.forEach(function(endpoint) {
219
230
220
231
< %- resultVariableDeclaration % >
221
232
args := map[string]interface {}{
222
- < %- formatParamsAsGolangMap (params) % >
233
+ < %- formatParamsAsGolangMap (params, method ) % >
223
234
}
224
235
err = stmt.< %- queryFunction % > (& result, args)
225
236
< % } else { -% >
@@ -246,7 +257,7 @@ endpoints.forEach(function(endpoint) {
246
257
json .NewDecoder (r .Body ).Decode (& body)
247
258
248
259
args := map[string]interface {}{
249
- < %- formatParamsAsGolangMap (params) % >
260
+ < %- formatParamsAsGolangMap (params, method ) % >
250
261
}
251
262
_, err := db .NamedExec (
252
263
" <%- formatQuery(method.query) %>" ,
@@ -269,7 +280,7 @@ endpoints.forEach(function(endpoint) {
269
280
json .NewDecoder (r .Body ).Decode (& body)
270
281
271
282
args := map[string]interface {}{
272
- < %- formatParamsAsGolangMap (params) % >
283
+ < %- formatParamsAsGolangMap (params, method ) % >
273
284
}
274
285
_, err := db .NamedExec (
275
286
" <%- formatQuery(method.query) %>" ,
@@ -289,7 +300,7 @@ endpoints.forEach(function(endpoint) {
289
300
% >
290
301
r .Delete (" <%- path %>" , func (w http .ResponseWriter , r * http .Request ) {
291
302
args := map[string]interface {}{
292
- < %- formatParamsAsGolangMap (params) % >
303
+ < %- formatParamsAsGolangMap (params, method ) % >
293
304
}
294
305
_, err := db .NamedExec (
295
306
" <%- formatQuery(method.query) %>" ,
0 commit comments