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:
parent
7a6a2b6373
commit
107bd74187
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user