1234567891011121314151617181920212223242526 |
- package main
- import (
- "context"
- "encoding/json"
- "fmt"
- "time"
- "github.com/google/uuid"
- )
- // HandleDummy is blissfully unaware of SQS, and could therefore be used as a handler for another message queue.
- func HandleDummy(_ context.Context, enc *json.Encoder, msg []byte) error {
- type EventBody struct {
- EventID uuid.UUID `json:"event_id"`
- EventTime time.Time `json:"event_time"`
- Data map[string]int `json:"data,omitempty"`
- }
- evt := EventBody{}
- if err := json.Unmarshal(msg, &evt); err != nil {
- return fmt.Errorf("error parsing body as JSON: %w", err)
- }
- enc.Encode(evt)
- return nil
- }
|