mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-04-26 21:05:30 +00:00
allow struct based processors to also operate on pointers to structs
This commit is contained in:
@@ -18,7 +18,11 @@ func (sm *StructMethodGet) Process(ctx context.Context, payload any) (any, error
|
||||
s := reflect.ValueOf(payload)
|
||||
|
||||
if s.Kind() != reflect.Struct {
|
||||
return nil, errors.New("struct.method.get processor only accepts a struct payload")
|
||||
if s.Kind() == reflect.Pointer && s.Elem().Kind() == reflect.Struct {
|
||||
s = s.Elem()
|
||||
} else {
|
||||
return nil, errors.New("struct.method.get processor only accepts a struct payload")
|
||||
}
|
||||
}
|
||||
|
||||
method := s.MethodByName(sm.Name)
|
||||
|
||||
Reference in New Issue
Block a user