func (e Event) MarshalLogObject(enc zapcore.ObjectEncoder) error {
	enc.AddString("eventType", string(e.EventType))
	if e.EventTypeVersion != "" {
		enc.AddString("eventTypeVersion", e.EventTypeVersion)
	}
	enc.AddString("cloudEventsVersion", e.CloudEventsVersion)
	enc.AddString("source", e.Source)
	enc.AddString("eventID", e.EventID)
	if e.EventTime != nil {
		enc.AddString("eventTime", e.EventTime.String())
	}
	if e.SchemaURL != "" {
		enc.AddString("schemaURL", e.SchemaURL)
	}
	if e.ContentType != "" {
		enc.AddString("contentType", e.ContentType)
	}
	if e.Extensions != nil {
		enc.AddObject("extensions", e.Extensions)
	}
	payload, _ := json.Marshal(e.Data)
	enc.AddString("data", string(payload))
	return nil
}
MarshalLogObject is a part of zapcore.ObjectMarshaler interface
package event
import (
	"encoding/json"
	"errors"
	"io/ioutil"
	"mime"
	"net/http"
	"strings"
	"time"
	"unicode"
	"go.uber.org/zap/zapcore"
	"github.com/satori/go.uuid"
	ihttp "github.com/serverless/event-gateway/internal/http"
	"github.com/serverless/event-gateway/internal/zap"
	"gopkg.in/go-playground/validator.v9"
)
const (
	TransformationVersion = "0.1"
	CloudEventsVersion = "0.1"
)
type Event struct {
	EventType          TypeName               `json:"eventType" validate:"required"`
	EventTypeVersion   string                 `json:"eventTypeVersion,omitempty"`
	CloudEventsVersion string                 `json:"cloudEventsVersion" validate:"required"`
	Source             string                 `json:"source" validate:"uri,required"`
	EventID            string                 `json:"eventID" validate:"required"`
	EventTime          *time.Time             `json:"eventTime,omitempty"`
	SchemaURL          string                 `json:"schemaURL,omitempty"`
	Extensions         zap.MapStringInterface `json:"extensions,omitempty"`
	ContentType        string                 `json:"contentType,omitempty"`
	Data               interface{}            `json:"data"`
}
func New(eventType TypeName, mimeType string, payload interface{}) *Event {
	now := time.Now()
	event := &Event{
		EventType:          eventType,
		CloudEventsVersion: CloudEventsVersion,
		Source:             "https://serverless.com/event-gateway/#transformationVersion=" + TransformationVersion,
		EventID:            uuid.NewV4().String(),
		EventTime:          &now,
		ContentType:        mimeType,
		Data:               payload,
		Extensions: map[string]interface{}{
			"eventgateway": map[string]interface{}{
				"transformed":            "true",
				"transformation-version": TransformationVersion,
			},
		},
	}
	event.Data = normalizePayload(event.Data, event.ContentType)
	return event
}
func FromRequest(r *http.Request) (*Event, error) {
	contentType := r.Header.Get("Content-Type")
	mimeType, _, err := mime.ParseMediaType(contentType)
	if err != nil {
		if err.Error() != "mime: no media type" {
			return nil, err
		}
		mimeType = "application/octet-stream"
	}
	body := []byte{}
	if r.Body != nil {
		body, err = ioutil.ReadAll(r.Body)
		if err != nil {
			return nil, err
		}
	}
	var event *Event
	if mimeType == mimeCloudEventsJSON {  
		return parseAsCloudEvent(mimeType, body)
	} else if isCloudEventsBinaryContentMode(r.Header) {  
		return parseAsCloudEventBinary(r.Header, body)
	} else if isLegacyMode(r.Header) {
		if mimeType == mimeJSON {  
			event, err = parseAsCloudEvent(mimeType, body)
			if err != nil {
				return New(TypeName(r.Header.Get("event")), mimeType, body), nil
			}
			return event, err
		}
		return New(TypeName(r.Header.Get("event")), mimeType, body), nil
	}
	return New(TypeHTTPRequest, mimeJSON, NewHTTPRequestData(r, body)), nil
}
func (e *Event) Validate() error {
	validate := validator.New()
	err := validate.Struct(e)
	if err != nil {
		return &ErrParsingCloudEvent{Message: err.Error()}
	}
	return nil
}
func (e *Event) IsSystem() bool {
	return strings.HasPrefix(string(e.EventType), "eventgateway.")
}