item

package
v0.0.0-...-36288e9 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2024 License: BSD-3-Clause Imports: 2 Imported by: 3

Documentation

Overview

Package item provides the default functionality to Ponzu's entities/data types, how they interact with the API, and how to override or enhance their abilities using various interfaces.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CSVFormattable

type CSVFormattable interface {
	FormatCSV() []string
}

CSVFormattable is implemented with the method FormatCSV, which must return the ordered slice of JSON struct tag names for the type implementing it

type Hookable

type Hookable interface {
	BeforeAPIResponse(http.ResponseWriter, *http.Request, interface{}) (interface{}, error)
	AfterAPIResponse(http.ResponseWriter, *http.Request, interface{}) error

	BeforeAPICreate(http.ResponseWriter, *http.Request) error
	AfterAPICreate(http.ResponseWriter, *http.Request) error

	BeforeAPIUpdate(http.ResponseWriter, *http.Request) error
	AfterAPIUpdate(http.ResponseWriter, *http.Request) error

	BeforeAPIDelete(http.ResponseWriter, *http.Request) error
	AfterAPIDelete(http.ResponseWriter, *http.Request) error

	BeforeAdminCreate(http.ResponseWriter, *http.Request) error
	AfterAdminCreate(http.ResponseWriter, *http.Request) error

	BeforeAdminUpdate(http.ResponseWriter, *http.Request) error
	AfterAdminUpdate(http.ResponseWriter, *http.Request) error

	BeforeAdminDelete(http.ResponseWriter, *http.Request) error
	AfterAdminDelete(http.ResponseWriter, *http.Request) error

	BeforeSave(http.ResponseWriter, *http.Request) error
	AfterSave(http.ResponseWriter, *http.Request) error

	BeforeDelete(http.ResponseWriter, *http.Request) error
	AfterDelete(http.ResponseWriter, *http.Request) error

	BeforeReject(http.ResponseWriter, *http.Request) error
	AfterReject(http.ResponseWriter, *http.Request) error

	BeforeEnable(http.ResponseWriter, *http.Request) error
	AfterEnable(http.ResponseWriter, *http.Request) error

	BeforeDisable(http.ResponseWriter, *http.Request) error
	AfterDisable(http.ResponseWriter, *http.Request) error
}

Hookable provides our user with an easy way to intercept or add functionality to the different lifecycles/events a struct may encounter. Item implements Hookable with no-ops so our user can override only whichever ones necessary.

type Identifiable

type Identifiable interface {
	ItemID() string
	SetItemID(string)
}

Identifiable enables a struct to have its ID set/get. Typically, this is done to set an ID to -1 indicating it is new for DB inserts, since by default a newly initialized struct would have an ID of 0, the int zero-value, and BoltDB's starting key per bucket is 0, thus overwriting the first record.

type Item

type Item struct {
	ID        string `json:"id"`
	Slug      string `json:"slug"`
	Timestamp int64  `json:"timestamp"`
	Updated   int64  `json:"updated"`
}

Item should only be embedded into entities type structs.

func (*Item) AfterAPICreate

func (i *Item) AfterAPICreate(res http.ResponseWriter, req *http.Request) error

AfterAPICreate is a no-op to ensure structs which embed Item implement Hookable

func (*Item) AfterAPIDelete

func (i *Item) AfterAPIDelete(res http.ResponseWriter, req *http.Request) error

AfterAPIDelete is a no-op to ensure structs which embed Item implement Hookable

func (*Item) AfterAPIResponse

func (i *Item) AfterAPIResponse(res http.ResponseWriter, req *http.Request, data interface{}) error

AfterAPIResponse is a no-op to ensure structs which embed Item implement Hookable

func (*Item) AfterAPIUpdate

func (i *Item) AfterAPIUpdate(res http.ResponseWriter, req *http.Request) error

AfterAPIUpdate is a no-op to ensure structs which embed Item implement Hookable

func (*Item) AfterAdminCreate

func (i *Item) AfterAdminCreate(res http.ResponseWriter, req *http.Request) error

AfterAdminCreate is a no-op to ensure structs which embed Item implement Hookable

func (*Item) AfterAdminDelete

func (i *Item) AfterAdminDelete(res http.ResponseWriter, req *http.Request) error

AfterAdminDelete is a no-op to ensure structs which embed Item implement Hookable

func (*Item) AfterAdminUpdate

func (i *Item) AfterAdminUpdate(res http.ResponseWriter, req *http.Request) error

AfterAdminUpdate is a no-op to ensure structs which embed Item implement Hookable

func (*Item) AfterDelete

func (i *Item) AfterDelete(res http.ResponseWriter, req *http.Request) error

AfterDelete is a no-op to ensure structs which embed Item implement Hookable

func (*Item) AfterDisable

func (i *Item) AfterDisable(res http.ResponseWriter, req *http.Request) error

AfterDisable is a no-op to ensure structs which embed Item implement Hookable

func (*Item) AfterEnable

func (i *Item) AfterEnable(res http.ResponseWriter, req *http.Request) error

AfterEnable is a no-op to ensure structs which embed Item implement Hookable

func (*Item) AfterReject

func (i *Item) AfterReject(res http.ResponseWriter, req *http.Request) error

AfterReject is a no-op to ensure structs which embed Item implement Hookable

func (*Item) AfterSave

func (i *Item) AfterSave(res http.ResponseWriter, req *http.Request) error

AfterSave is a no-op to ensure structs which embed Item implement Hookable

func (*Item) BeforeAPICreate

func (i *Item) BeforeAPICreate(res http.ResponseWriter, req *http.Request) error

BeforeAPICreate is a no-op to ensure structs which embed Item implement Hookable

func (*Item) BeforeAPIDelete

func (i *Item) BeforeAPIDelete(res http.ResponseWriter, req *http.Request) error

BeforeAPIDelete is a no-op to ensure structs which embed Item implement Hookable

func (*Item) BeforeAPIResponse

func (i *Item) BeforeAPIResponse(res http.ResponseWriter, req *http.Request, data interface{}) (interface{}, error)

BeforeAPIResponse is a no-op to ensure structs which embed Item implement Hookable

func (*Item) BeforeAPIUpdate

func (i *Item) BeforeAPIUpdate(res http.ResponseWriter, req *http.Request) error

BeforeAPIUpdate is a no-op to ensure structs which embed Item implement Hookable

func (*Item) BeforeAdminCreate

func (i *Item) BeforeAdminCreate(res http.ResponseWriter, req *http.Request) error

BeforeAdminCreate is a no-op to ensure structs which embed Item implement Hookable

func (*Item) BeforeAdminDelete

func (i *Item) BeforeAdminDelete(res http.ResponseWriter, req *http.Request) error

BeforeAdminDelete is a no-op to ensure structs which embed Item implement Hookable

func (*Item) BeforeAdminUpdate

func (i *Item) BeforeAdminUpdate(res http.ResponseWriter, req *http.Request) error

BeforeAdminUpdate is a no-op to ensure structs which embed Item implement Hookable

func (*Item) BeforeDelete

func (i *Item) BeforeDelete(res http.ResponseWriter, req *http.Request) error

BeforeDelete is a no-op to ensure structs which embed Item implement Hookable

func (*Item) BeforeDisable

func (i *Item) BeforeDisable(res http.ResponseWriter, req *http.Request) error

BeforeDisable is a no-op to ensure structs which embed Item implement Hookable

func (*Item) BeforeEnable

func (i *Item) BeforeEnable(res http.ResponseWriter, req *http.Request) error

BeforeEnable is a no-op to ensure structs which embed Item implement Hookable

func (*Item) BeforeReject

func (i *Item) BeforeReject(res http.ResponseWriter, req *http.Request) error

BeforeReject is a no-op to ensure structs which embed Item implement Hookable

func (*Item) BeforeSave

func (i *Item) BeforeSave(res http.ResponseWriter, req *http.Request) error

BeforeSave is a no-op to ensure structs which embed Item implement Hookable

func (*Item) CreatedAt

func (i *Item) CreatedAt() int64

func (*Item) IndexContent

func (i *Item) IndexContent() bool

IndexContent determines if a type should be indexed for searching partially implements search.Searchable

func (*Item) ItemID

func (i *Item) ItemID() string

ItemID gets the Item's ID field partially implements the Identifiable interface

func (*Item) ItemSlug

func (i *Item) ItemSlug() string

ItemSlug sets the item's slug for its URL

func (*Item) SetCreatedAt

func (i *Item) SetCreatedAt(t time.Time)

func (*Item) SetItemID

func (i *Item) SetItemID(id string)

SetItemID sets the Item's ID field partially implements the Identifiable interface

func (*Item) SetSlug

func (i *Item) SetSlug(slug string)

SetSlug sets the item's slug for its URL

func (*Item) SetUpdatedAt

func (i *Item) SetUpdatedAt(t time.Time)

func (*Item) Time

func (i *Item) Time() int64

Time partially implements the Sortable interface

func (*Item) Touch

func (i *Item) Touch() int64

Touch partially implements the Sortable interface

func (*Item) UpdatedAt

func (i *Item) UpdatedAt() int64

type Readable

type Readable interface {
	GetTitle() string
}

Readable enables an entity to have a Title property

type Sluggable

type Sluggable interface {
	Readable
	SetSlug(string)
	ItemSlug() string
}

type Sortable

type Sortable interface {
	Time() int64
	Touch() int64
}

Sortable ensures data is sortable by time

type Temporal

type Temporal interface {
	CreatedAt() int64
	SetCreatedAt(time.Time)
	UpdatedAt() int64
	SetUpdatedAt(time.Time)
}

Jump to

Keyboard shortcuts

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