Initial cloud-services repo - gateway service + pkg modules
This commit is contained in:
23
pkg/common/payload.go
Normal file
23
pkg/common/payload.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// Payload is the generic structure for payloads sent within Kafka messages
|
||||
type Payload struct {
|
||||
Handler string `json:"handler"`
|
||||
Data json.RawMessage `json:"data"`
|
||||
}
|
||||
|
||||
func (p *Payload) Marshal() ([]byte, error) {
|
||||
data, err := json.Marshal(*p)
|
||||
return data, errors.WithStack(err)
|
||||
}
|
||||
|
||||
func (p *Payload) Unmarshal(data []byte) error {
|
||||
err := json.Unmarshal(data, p)
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
Reference in New Issue
Block a user