Skip to content

Commit

Permalink
Rebase conflicts
Browse files Browse the repository at this point in the history
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
  • Loading branch information
slinkydeveloper committed Jan 7, 2021
1 parent c30113b commit 3ce0094
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 deletions v2/event/event_marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@ package event

import (
"bytes"
"context"
"encoding/base64"
"fmt"
"io"
"strings"

jsoniter "github.com/json-iterator/go"

"github.com/cloudevents/sdk-go/v2/observability"
)

// WriteJson writes the in event in the provided writer.
Expand Down Expand Up @@ -193,21 +190,7 @@ func WriteJson(in *Event, writer io.Writer) error {
// MarshalJSON implements a custom json marshal method used when this type is
// marshaled using json.Marshal.
func (e Event) MarshalJSON() ([]byte, error) {
_, r := observability.NewReporter(context.Background(), eventJSONObserved{o: reportMarshal, v: e.SpecVersion()})

if err := e.Validate(); err != nil {
r.Error()
return nil, err
}

var buf bytes.Buffer
err := WriteJson(&e, &buf)

// Report the observable
if err != nil {
r.Error()
return nil, err
}
r.OK()
return buf.Bytes(), nil
return buf.Bytes(), err
}

0 comments on commit 3ce0094

Please sign in to comment.