cmswebhook

package
v0.0.0-...-80539dc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 5, 2024 License: MIT Imports: 12 Imported by: 8

Documentation

Index

Constants

View Source
const (
	SignatureHeader      = "Reearth-Signature"
	EventItemCreate      = "item.create"
	EventItemUpdate      = "item.update"
	EventItemPublish     = "item.publish"
	EventAssetDecompress = "asset.decompress"
)

Variables

View Source
var Now = time.Now

Functions

func AttachPayload

func AttachPayload(ctx context.Context, p *Payload) context.Context

func Middleware

func Middleware(config MiddlewareConfig) func(http.Handler) http.Handler

Types

type AssetData

type AssetData cms.Asset

type Handler

type Handler func(*http.Request, *Payload) error

func MergeHandlers

func MergeHandlers(handlers []Handler) Handler

type Integration

type Integration struct {
	ID string `json:"id"`
}

type ItemData

type ItemData struct {
	Item            *cms.Item         `json:"item,omitempty"`
	Model           *cms.Model        `json:"model,omitempty"`
	Schema          *cms.Schema       `json:"schema,omitempty"`
	ReferencedItems []*cms.Item       `json:"referencedItems,omitempty"`
	Changes         []cms.FieldChange `json:"changes,omitempty"`
}

type Machine

type Machine struct{}

type MiddlewareConfig

type MiddlewareConfig struct {
	Secret []byte
	Logger func(ctx context.Context, format string, v ...any)
}

type Operator

type Operator struct {
	User        *User        `json:"user,omitempty"`
	Integration *Integration `json:"integration,omitempty"`
	Machine     *Machine     `json:"machine,omitempty"`
}

func (Operator) IsIntegration

func (o Operator) IsIntegration() bool

func (Operator) IsIntegrationBy

func (o Operator) IsIntegrationBy(iid string) bool

func (Operator) IsUser

func (o Operator) IsUser() bool

type Payload

type Payload struct {
	Type      string          `json:"type,omitempty"`
	Data      json.RawMessage `json:"data,omitempty"`
	AssetData *AssetData      `json:"-"`
	ItemData  *ItemData       `json:"-"`
	Operator  Operator        `json:"operator,omitempty"`
	Sig       string          `json:"-"`
	Body      []byte          `json:"-"`
}

func GetPayload

func GetPayload(ctx context.Context) *Payload

func (*Payload) MarshalJSON

func (p *Payload) MarshalJSON() (_ []byte, err error)

func (Payload) ProjectID

func (p Payload) ProjectID() string

func (*Payload) UnmarshalJSON

func (p *Payload) UnmarshalJSON(data []byte) error

type User

type User struct {
	ID string `json:"id"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL