1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-01-11 17:18:28 +02:00

fix: allow event subscribers to use pointers (#2514)

When a subscriber would use a pointer as event type, panics would occur.
This commit is contained in:
David Brouwer 2022-06-22 03:01:13 +02:00 committed by GitHub
parent 7a6a2b6373
commit 107bd74187
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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
}