Documentation ¶
Index ¶
- Variables
- func ById[T any](ctx context.Context, id string) (*T, error)
- func Call[T any](s *typutil.Callable, ctx context.Context, arg ...any) (T, error)deprecated
- func RegisterActions[T any](name string, actions *ObjectActions)
- func RegisterStatic(name string, fn any)
- func Static(method any) *typutil.Callabledeprecated
- type Object
- type ObjectActions
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
func Static
deprecated
Static returns a typutil.Callable object for a func that accepts a context.Context and/or a struct object that is its arguments.
Deprecated: use typutil.Func instead
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
type ObjectActions ¶
type ObjectActions struct { Fetch *typutil.Callable // Fetch action receives "id" and returns an instance (factory) List *typutil.Callable // List action returns a list of object Clear *typutil.Callable // Clear action deletes all objects and returns nothing Create *typutil.Callable // Create action creates a new object and returns it }
ObjectActions defines generic factories for usage in API calls
Click to show internal directories.
Click to hide internal directories.