Documentation ¶
Index ¶
- Variables
- func Slug(i Identifiable) (string, error)
- type Hideable
- type Hookable
- type Identifiable
- type Item
- func (i Item) AfterAccept(res http.ResponseWriter, req *http.Request) error
- func (i Item) AfterApprove(res http.ResponseWriter, req *http.Request) error
- func (i Item) AfterDelete(res http.ResponseWriter, req *http.Request) error
- func (i Item) AfterReject(res http.ResponseWriter, req *http.Request) error
- func (i Item) AfterSave(res http.ResponseWriter, req *http.Request) error
- func (i Item) BeforeAccept(res http.ResponseWriter, req *http.Request) error
- func (i Item) BeforeApprove(res http.ResponseWriter, req *http.Request) error
- func (i Item) BeforeDelete(res http.ResponseWriter, req *http.Request) error
- func (i Item) BeforeReject(res http.ResponseWriter, req *http.Request) error
- func (i Item) BeforeSave(res http.ResponseWriter, req *http.Request) error
- func (i Item) ItemID() int
- func (i *Item) ItemSlug() string
- func (i *Item) SetItemID(id int)
- func (i *Item) SetSlug(slug string)
- func (i Item) String() string
- func (i Item) Time() int64
- func (i Item) Touch() int64
- func (i Item) UniqueID() uuid.UUID
- type Omittable
- type Pushable
- type Sluggable
- type Sortable
Constants ¶
This section is empty.
Variables ¶
var ( // ErrTypeNotRegistered means content type isn't registered (not found in Types map) ErrTypeNotRegistered = errors.New(typeNotRegistered) // ErrAllowHiddenItem should be used as an error to tell a caller of Hideable#Hide // that this type is hidden, but should be shown in a particular case, i.e. // if requested by a valid admin or user ErrAllowHiddenItem = errors.New(`Allow hidden item`) // Types is a map used to reference a type name to its actual Editable type // mainly for lookups in /admin route based utilities Types map[string]func() interface{} )
Functions ¶
func Slug ¶
func Slug(i Identifiable) (string, error)
Slug returns a URL friendly string from the title of a post item
Types ¶
type Hideable ¶
type Hideable interface {
Hide(http.ResponseWriter, *http.Request) error
}
Hideable lets a user keep items hidden
type Hookable ¶
type Hookable interface { BeforeAccept(http.ResponseWriter, *http.Request) error AfterAccept(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 BeforeApprove(http.ResponseWriter, *http.Request) error AfterApprove(http.ResponseWriter, *http.Request) error BeforeReject(http.ResponseWriter, *http.Request) error AfterReject(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 ¶
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 { UUID uuid.UUID `json:"uuid"` ID int `json:"id"` Slug string `json:"slug"` Timestamp int64 `json:"timestamp"` Updated int64 `json:"updated"` }
Item should only be embedded into content type structs.
func (Item) AfterAccept ¶
AfterAccept is a no-op to ensure structs which embed Item implement Hookable
func (Item) AfterApprove ¶
AfterApprove is a no-op to ensure structs which embed Item implement Hookable
func (Item) AfterDelete ¶
AfterDelete is a no-op to ensure structs which embed Item implement Hookable
func (Item) AfterReject ¶
AfterReject is a no-op to ensure structs which embed Item implement Hookable
func (Item) BeforeAccept ¶
BeforeAccept is a no-op to ensure structs which embed Item implement Hookable
func (Item) BeforeApprove ¶
BeforeApprove is a no-op to ensure structs which embed Item implement Hookable
func (Item) BeforeDelete ¶
BeforeDelete is a no-op to ensure structs which embed Item implement Hookable
func (Item) BeforeReject ¶
BeforeReject is a no-op to ensure structs which embed Item implement Hookable
func (Item) BeforeSave ¶
BeforeSave is a no-op to ensure structs which embed Item implement Hookable
func (Item) ItemID ¶
ItemID gets the Item's ID field partially implements the Identifiable interface
func (*Item) SetItemID ¶
SetItemID sets the Item's ID field partially implements the Identifiable interface
type Omittable ¶
type Omittable interface {
Omit() []string
}
Omittable lets a user define certin fields within a content struct to remove from an API response. Helpful when you want data in the CMS, but not entirely shown or available from the content API. All items in the slice should be the json tag names of the struct fields to which they correspond.
type Pushable ¶
type Pushable interface { // the values contained by fields returned by Push must strictly be URL paths Push() []string }
Pushable lets a user define which values of certain struct fields are 'pushed' down to a client via HTTP/2 Server Push. All items in the slice should be the json tag names of the struct fields to which they correspond.