Skip to content

Commit 25edf4d

Browse files
committed
router: Detect proto in JSON handler.
1 parent 1ef0a90 commit 25edf4d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

router/module.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ func (m *Module) Proto(rw http.ResponseWriter, status int, pb proto.Message) err
7373

7474
// JSON renders a response with given status and JSON serialized data
7575
func (m *Module) JSON(rw http.ResponseWriter, status int, v interface{}) error {
76+
if pb, ok := v.(proto.Message); ok {
77+
return m.Proto(rw, status, pb)
78+
}
79+
7680
b, err := json.MarshalIndent(v, "", " ")
7781
if err != nil {
7882
return err

0 commit comments

Comments
 (0)