GetProcessor returns the processor for a media-type
(ctx context.Context, stream StreamProcessor, payloads map[string]typeurl.Any)
| 47 | |
| 48 | // GetProcessor returns the processor for a media-type |
| 49 | func GetProcessor(ctx context.Context, stream StreamProcessor, payloads map[string]typeurl.Any) (StreamProcessor, error) { |
| 50 | // reverse this list so that user configured handlers come up first |
| 51 | for i := len(handlers) - 1; i >= 0; i-- { |
| 52 | processor, ok := handlers[i](ctx, stream.MediaType()) |
| 53 | if ok { |
| 54 | return processor(ctx, stream, payloads) |
| 55 | } |
| 56 | } |
| 57 | return nil, ErrNoProcessor |
| 58 | } |
| 59 | |
| 60 | // Handler checks a media-type and initializes the processor |
| 61 | type Handler func(ctx context.Context, mediaType string) (StreamProcessorInit, bool) |