comparison pkg/controllers/surveys.go @ 4242:1458c9b0fdaa json-handler-middleware

Made the sql.Conn in function accessible via the context of the request.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 22 Aug 2019 10:18:13 +0200
parents 80e9cfb2be98
children d776110b4db0
comparison
equal deleted inserted replaced
4240:a4f76e170290 4242:1458c9b0fdaa
42 ) 42 )
43 43
44 func listSurveys( 44 func listSurveys(
45 _ interface{}, 45 _ interface{},
46 req *http.Request, 46 req *http.Request,
47 db *sql.Conn,
48 ) (jr JSONResult, err error) { 47 ) (jr JSONResult, err error) {
49 48
50 bottleneckName := mux.Vars(req)["bottleneck"] 49 bottleneckName := mux.Vars(req)["bottleneck"]
51 50
52 var rows *sql.Rows 51 var rows *sql.Rows
53 52
54 rows, err = db.QueryContext(req.Context(), listSurveysSQL, bottleneckName) 53 rows, err = JSONConn(req).QueryContext(req.Context(), listSurveysSQL, bottleneckName)
55 if err != nil { 54 if err != nil {
56 return 55 return
57 } 56 }
58 defer rows.Close() 57 defer rows.Close()
59 58