Skip to content

Commit 94bd43c

Browse files
committed
Merge pull request 'add validate subscriber signature func' (#411) from devstigneev/micro:v3_validate_subs into v3
Reviewed-on: https://git.unistack.org/unistack-org/micro/pulls/411
2 parents b4433c4 + 43f77be commit 94bd43c

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

server/noop.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,10 @@ func newSubscriber(topic string, sub interface{}, opts ...SubscriberOption) Subs
534534
h.reqType = typ.In(1)
535535
}
536536

537+
if h.reqType.Kind() == reflect.Interface {
538+
panic(fmt.Sprintf("subscriber for %s: request type cannot be interface{} or any", topic))
539+
}
540+
537541
handlers = append(handlers, h)
538542
} else {
539543
for m := 0; m < typ.NumMethod(); m++ {
@@ -550,6 +554,10 @@ func newSubscriber(topic string, sub interface{}, opts ...SubscriberOption) Subs
550554
h.reqType = method.Type.In(2)
551555
}
552556

557+
if h.reqType.Kind() == reflect.Interface {
558+
panic(fmt.Sprintf("subscriber for %s: request type cannot be interface{} or any", topic))
559+
}
560+
553561
handlers = append(handlers, h)
554562
}
555563
}

0 commit comments

Comments
 (0)