-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4921daa
commit 9c4ec4a
Showing
4 changed files
with
48 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package gtag | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"github.com/ThreeDotsLabs/watermill/message" | ||
"github.com/foomo/sesamy-go/pkg/encoding/gtag" | ||
"github.com/pkg/errors" | ||
) | ||
|
||
func NoPublishMessageHandler(handler func(payload *gtag.Payload, msg *message.Message) error) func(msg *message.Message) error { | ||
return func(msg *message.Message) error { | ||
var payload *gtag.Payload | ||
|
||
// unmarshal payload | ||
if err := json.Unmarshal(msg.Payload, &payload); err != nil { | ||
return errors.Wrap(err, "failed to unmarshal payload") | ||
} | ||
|
||
// handle payload | ||
return handler(payload, msg) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package mpv2 | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"github.com/ThreeDotsLabs/watermill/message" | ||
"github.com/foomo/sesamy-go/pkg/encoding/mpv2" | ||
"github.com/pkg/errors" | ||
) | ||
|
||
func NoPublishMessageHandler(handler func(payload *mpv2.Payload[any], msg *message.Message) error) message.NoPublishHandlerFunc { | ||
return func(msg *message.Message) error { | ||
var payload *mpv2.Payload[any] | ||
|
||
// unmarshal payload | ||
if err := json.Unmarshal(msg.Payload, &payload); err != nil { | ||
return errors.Wrap(err, "failed to unmarshal payload") | ||
} | ||
|
||
// handle payload | ||
return handler(payload, msg) | ||
} | ||
} |