mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-04-27 13:25:40 +00:00
36 lines
644 B
Go
36 lines
644 B
Go
package processing
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
)
|
|
|
|
type StringDecode struct {
|
|
config ProcessorConfig
|
|
}
|
|
|
|
func (sd *StringDecode) Process(ctx context.Context, payload any) (any, error) {
|
|
payloadBytes, ok := payload.([]byte)
|
|
|
|
if !ok {
|
|
return nil, fmt.Errorf("string.decode processor only accepts a []byte")
|
|
}
|
|
|
|
payloadMessage := string(payloadBytes)
|
|
|
|
return payloadMessage, nil
|
|
}
|
|
|
|
func (sd *StringDecode) Type() string {
|
|
return sd.config.Type
|
|
}
|
|
|
|
func init() {
|
|
RegisterProcessor(ProcessorRegistration{
|
|
Type: "string.decode",
|
|
New: func(config ProcessorConfig) (Processor, error) {
|
|
return &StringDecode{config: config}, nil
|
|
},
|
|
})
|
|
}
|