webhook

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func EnableViews

func EnableViews() error

func NewHTTPHandler

func NewHTTPHandler(fn Handler, opts ...Option) http.HandlerFunc

Types

type ActionType

type ActionType string

type Data

type Data struct {
	RawData  io.Reader `json:"-"`
	DataType DataType  `json:"data_type"`

	*EventData
	*DeviceData
	*PersonData
	*PlaceData
}

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 Handler

type Handler interface {
	ServeWebhook(context.Context, *Data) error
}

type HandlerFunc

type HandlerFunc func(context.Context, *Data) error

func ReportStats

func ReportStats(fn Handler) HandlerFunc

func (HandlerFunc) ServeWebhook

func (fn HandlerFunc) ServeWebhook(ctx context.Context, data *Data) error

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 PersonType `json:"personType"`
}

type PersonType

type PersonType string
const (
	PersonEmployee       PersonType = "0"
	PersonCustomer       PersonType = "1"
	PersonStranger       PersonType = "2"
	PersonStranger3      PersonType = "3"
	PersonStrangerNoFace PersonType = "4"
	PersonStranger5      PersonType = "5"
	PersonCameraPhoto    PersonType = "6"
)

func (PersonType) IsStranger

func (p PersonType) IsStranger() bool

func (PersonType) String

func (p PersonType) String() string

type PlaceData

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

Jump to

Keyboard shortcuts

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