From 2b0a0cf93bd0e4f5da60f3ffbee27e204c4b19d1 Mon Sep 17 00:00:00 2001 From: Josh Baker Date: Tue, 10 Apr 2018 11:54:13 -0700 Subject: [PATCH] Add meta data to hooks command Closes #296 --- controller/hooks.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/controller/hooks.go b/controller/hooks.go index cceddaac..544528c2 100644 --- a/controller/hooks.go +++ b/controller/hooks.go @@ -298,8 +298,16 @@ func (c *Controller) cmdHooks(msg *server.Message) (res resp.Value, err error) { } buf.WriteString(jsonString(v.String())) } - - buf.WriteString(`]}`) + buf.WriteString(`],"meta":{`) + for i, meta := range hook.Metas { + if i > 0 { + buf.WriteString(`,`) + } + buf.WriteString(jsonString(meta.Name)) + buf.WriteString(`:`) + buf.WriteString(jsonString(meta.Value)) + } + buf.WriteString(`}}`) } buf.WriteString(`],"elapsed":"` + time.Now().Sub(start).String() + "\"}") return resp.StringValue(buf.String()), nil @@ -315,6 +323,12 @@ func (c *Controller) cmdHooks(msg *server.Message) (res resp.Value, err error) { } hvals = append(hvals, resp.ArrayValue(evals)) hvals = append(hvals, resp.ArrayValue(hook.Message.Values)) + var metas []resp.Value + for _, meta := range hook.Metas { + metas = append(metas, resp.StringValue(meta.Name)) + metas = append(metas, resp.StringValue(meta.Value)) + } + hvals = append(hvals, resp.ArrayValue(metas)) vals = append(vals, resp.ArrayValue(hvals)) } return resp.ArrayValue(vals), nil