Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrUnknownType = errors.New("pobj: unknown object type") ErrMissingAction = errors.New("pobj: no such action exists") )
Functions ¶
func RegisterActions ¶
func RegisterActions[T any](name string, actions *ObjectActions)
RegisterActions is used for static REST methods such as get (factory) and list. Methods such as update and delete require an object.
func RegisterStatic ¶
RegisterStatic adds a static method to an object
Types ¶
type Object ¶
type Object struct { Action *ObjectActions // contains filtered or unexported fields }
func Get ¶ added in v0.1.0
Get returns the Object matching the given name, or nil if no such object exists
func GetByType ¶ added in v0.1.0
GetByType returns the Object matching the type given on the command line
func (*Object) Static ¶
func (o *Object) Static(name string) *StaticMethod
Static returns the given static method
type ObjectActions ¶
type ObjectActions struct { Fetch *StaticMethod // Fetch action receives "id" and returns an instance (factory) List *StaticMethod // List action returns a list of object Clear *StaticMethod // Clear action deletes all objects and returns nothing Create *StaticMethod // Create action creates a new object and returns it }
ObjectActions defines generic factories for usage in API calls
type StaticMethod ¶
type StaticMethod struct {
// contains filtered or unexported fields
}
func Static ¶
func Static(method any) *StaticMethod
Static returns a StaticMethod object for a func that accepts a context.Context and/or a struct object that is its arguments.
Click to show internal directories.
Click to hide internal directories.