Mercurial > gemma
comparison controllers/json.go @ 239:713234a04a87
Renamed JSONHandler.Process to JSONHandler.Handler as it sounds more symmetrical.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 26 Jul 2018 17:15:22 +0200 |
parents | 2b39bf2bf1fd |
children | 9012e4045da4 |
comparison
equal
deleted
inserted
replaced
238:2b39bf2bf1fd | 239:713234a04a87 |
---|---|
15 Code int | 15 Code int |
16 Result interface{} | 16 Result interface{} |
17 } | 17 } |
18 | 18 |
19 type JSONHandler struct { | 19 type JSONHandler struct { |
20 Input func() interface{} | 20 Input func() interface{} |
21 Process func(http.ResponseWriter, *http.Request, interface{}, *sql.DB) (JSONResult, error) | 21 Handle func(http.ResponseWriter, *http.Request, interface{}, *sql.DB) (JSONResult, error) |
22 } | 22 } |
23 | 23 |
24 type JSONError struct { | 24 type JSONError struct { |
25 Code int | 25 Code int |
26 Message string | 26 Message string |
43 } | 43 } |
44 | 44 |
45 token, _ := auth.GetToken(req) | 45 token, _ := auth.GetToken(req) |
46 var jr JSONResult | 46 var jr JSONResult |
47 err := auth.ConnPool.Do(token, func(db *sql.DB) (err error) { | 47 err := auth.ConnPool.Do(token, func(db *sql.DB) (err error) { |
48 jr, err = j.Process(rw, req, input, db) | 48 jr, err = j.Handle(rw, req, input, db) |
49 return err | 49 return err |
50 }) | 50 }) |
51 | 51 |
52 if err != nil { | 52 if err != nil { |
53 switch e := err.(type) { | 53 switch e := err.(type) { |