mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-08-14 10:53:38 +00:00
move init functions to top of file
This commit is contained in:
@@ -11,31 +11,6 @@ import (
|
||||
"github.com/jwetzell/showbridge-go/internal/config"
|
||||
)
|
||||
|
||||
type StringCreate struct {
|
||||
config config.ProcessorConfig
|
||||
Template *template.Template
|
||||
}
|
||||
|
||||
func (sc *StringCreate) Process(ctx context.Context, wrappedPayload common.WrappedPayload) (common.WrappedPayload, error) {
|
||||
templateData := wrappedPayload
|
||||
|
||||
var templateBuffer bytes.Buffer
|
||||
err := sc.Template.Execute(&templateBuffer, templateData)
|
||||
|
||||
if err != nil {
|
||||
wrappedPayload.End = true
|
||||
return wrappedPayload, err
|
||||
}
|
||||
|
||||
wrappedPayload.Payload = templateBuffer.String()
|
||||
|
||||
return wrappedPayload, nil
|
||||
}
|
||||
|
||||
func (sc *StringCreate) Type() string {
|
||||
return sc.config.Type
|
||||
}
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "string.create",
|
||||
@@ -67,3 +42,28 @@ func init() {
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
type StringCreate struct {
|
||||
config config.ProcessorConfig
|
||||
Template *template.Template
|
||||
}
|
||||
|
||||
func (sc *StringCreate) Process(ctx context.Context, wrappedPayload common.WrappedPayload) (common.WrappedPayload, error) {
|
||||
templateData := wrappedPayload
|
||||
|
||||
var templateBuffer bytes.Buffer
|
||||
err := sc.Template.Execute(&templateBuffer, templateData)
|
||||
|
||||
if err != nil {
|
||||
wrappedPayload.End = true
|
||||
return wrappedPayload, err
|
||||
}
|
||||
|
||||
wrappedPayload.Payload = templateBuffer.String()
|
||||
|
||||
return wrappedPayload, nil
|
||||
}
|
||||
|
||||
func (sc *StringCreate) Type() string {
|
||||
return sc.config.Type
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user