webhook

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ActionAdd    = ActionType("add")
	ActionDetele = ActionType("delete")
	ActionUpdate = ActionType("update")
)
View Source
const (
	DataDevice = DataType("device")
	DataLog    = DataType("log")
	DataPerson = DataType("person")
	DataPlace  = DataType("place")
)

Variables

This section is empty.

Functions

func EnableViews

func EnableViews() error

func Handler

func Handler(fn WebhookFn, optsFn ...Option) http.Handler

Types

type ActionType

type ActionType string

type DataType

type DataType string

type DeviceData

type DeviceData struct {
	DeviceID   string `json:"deviceID"`
	DeviceName string `json:"deviceName"`
}

type EventData

type EventData struct {
	ActionType ActionType `json:"action_type"`
	Date       string     `json:"date"`
	KeyCode    string     `json:"keycode"`

	Hash string `json:"hash"`
	ID   string `json:"id"`
	Time uint64 `json:"time"`
}

type IntID

type IntID int

func (IntID) Int

func (id IntID) Int() int

func (*IntID) UnmarshalJSON

func (id *IntID) UnmarshalJSON(data []byte) (err error)

type Option

type Option = func(*Options)

func WithOnError

func WithOnError(fn func(context.Context, error)) Option

func WithSecretVerify

func WithSecretVerify(secret []byte) Option

func WithStats

func WithStats() Option

type Options

type Options struct {
	OnError func(context.Context, error)
	Stats   bool
	Verify  func(*EventData) bool
}

type PersonData

type PersonData struct {
	DetectedImageURL string `json:"detected_image_url"`
	PersonID         string `json:"personID"`
	AliasID          string `json:"aliasID"`
	PersonName       string `json:"personName"`
	PersonType       string `json:"personType"`
}

type PlaceData

type PlaceData struct {
	PlaceID   IntID  `json:"placeID"`
	PlaceName string `json:"placeName"`
}

type Webhook

type Webhook struct {
	DataType DataType `json:"data_type"`

	*EventData
	*DeviceData
	*PersonData
	*PlaceData
}

type WebhookFn

type WebhookFn func(context.Context, *Webhook) error

func ReportStats

func ReportStats(fn WebhookFn) WebhookFn

Jump to

Keyboard shortcuts

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