mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-04-27 05:15:47 +00:00
36 lines
606 B
Go
36 lines
606 B
Go
package common
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
type WrappedPayload struct {
|
|
Payload any
|
|
Modules any
|
|
Sender any
|
|
Source string
|
|
End bool
|
|
}
|
|
|
|
func GetWrappedPayload(ctx context.Context, payload any) WrappedPayload {
|
|
templateData := WrappedPayload{
|
|
Payload: payload,
|
|
End: false,
|
|
}
|
|
modules := ctx.Value(ModulesContextKey)
|
|
if modules != nil {
|
|
templateData.Modules = modules
|
|
}
|
|
|
|
sender := ctx.Value(SenderContextKey)
|
|
if sender != nil {
|
|
templateData.Sender = sender
|
|
}
|
|
|
|
source := ctx.Value(SourceContextKey)
|
|
if source != nil {
|
|
templateData.Source = source.(string)
|
|
}
|
|
return templateData
|
|
}
|