From 107bd74187e7cf0f0d7f67b28662bea6bdc3f5e9 Mon Sep 17 00:00:00 2001 From: David Brouwer Date: Wed, 22 Jun 2022 03:01:13 +0200 Subject: [PATCH] fix: allow event subscribers to use pointers (#2514) When a subscriber would use a pointer as event type, panics would occur. --- server/rpc_router.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/server/rpc_router.go b/server/rpc_router.go index bcef5bb3..f05d1973 100644 --- a/server/rpc_router.go +++ b/server/rpc_router.go @@ -556,8 +556,14 @@ func (router *router) ProcessMessage(ctx context.Context, msg Message) (err erro return err } + // make request value a pointer, if it's not already + reqVal := req.Interface() + if req.CanAddr() { + reqVal = req.Addr().Interface() + } + // read the body into the handler request value - if err = cc.ReadBody(req.Addr().Interface()); err != nil { + if err = cc.ReadBody(reqVal); err != nil { return err }