Documentation
¶
Index ¶
- func CRUDEntitiesToOutput[Entity any, Output any](entities []Entity, apiFields input.APIFields, tableName string) *Output
- func CRUDEntitiesToOutputs[Entity any, Output any](entities []Entity, apiFields input.APIFields, tableName string) []Output
- type CRUDClient
- type CreateClient
- type DefaultClients
- type DeleteClient
- type GetClient
- type UpdateClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CRUDEntitiesToOutput ¶
func CRUDEntitiesToOutput[Entity any, Output any]( entities []Entity, apiFields input.APIFields, tableName string, ) *Output
CRUDEntitiesToOutput converts a slice of entities to a single output.
Parameters:
- entities: The entities to convert.
- apiFields: The API fields to use for mapping.
- tableName: The name of the table to use for mapping.
Returns:
- Output: The output.
func CRUDEntitiesToOutputs ¶
func CRUDEntitiesToOutputs[Entity any, Output any]( entities []Entity, apiFields input.APIFields, tableName string, ) []Output
CRUDEntitiesToOutputs converts a slice of entities to a slice of outputs.
Parameters:
- entities: The entities to convert.
- apiFields: The API fields to use for mapping.
- tableName: The name of the table to use for mapping.
Returns:
- []Output: The outputs.
Types ¶
type CRUDClient ¶
type CRUDClient struct {
// contains filtered or unexported fields
}
CRUDClient is a base client with common configuration.
func NewDefaultClient ¶
func NewDefaultClient(url string) *CRUDClient
NewDefaultClient creates a new base client.
type CreateClient ¶
type CreateClient[Input, Output any] struct { *CRUDClient }
CreateClient is a generic wrapper for the create endpoint.
func NewCreateClient ¶
func NewCreateClient[Input, Output any]( base *CRUDClient, ) *CreateClient[Input, Output]
NewCreateClient creates a new CreateClient given a base client.
type DefaultClients ¶
type DefaultClients[CreateInput any, CreateOutput any, GetOutput any] struct { Create *CreateClient[CreateInput, json.APIOutput[CreateOutput]] Get *GetClient[setup.DefaultGetInput, json.APIOutput[GetOutput]] Update *UpdateClient[setup.DefaultUpdateInput, json.APIOutput[setup.DefaultUpdateOutput]] Delete *DeleteClient[setup.DefaultDeleteInput, json.APIOutput[setup.DefaultDeleteOutput]] }
DefaultClients groups the CRUD clients into a single struct.
func NewDefaultClients ¶
func NewDefaultClients[CreateInput any, CreateOutput any, GetOutput any]( url string, ) *DefaultClients[CreateInput, CreateOutput, GetOutput]
NewDefaultClients creates a new set of CRUD clients for the given URL.
type DeleteClient ¶
type DeleteClient[Input any, Output any] struct { *CRUDClient }
DeleteClient is a generic wrapper for the delete endpoint.
func NewDeleteClient ¶
func NewDeleteClient[Input any, Output any]( base *CRUDClient, ) *DeleteClient[Input, Output]
NewDeleteClient creates a new DeleteClient given a base client.
type GetClient ¶
type GetClient[Input any, Output any] struct { *CRUDClient }
GetClient is a generic wrapper for the get endpoint.
func NewGetClient ¶
func NewGetClient[Input any, Output any]( base *CRUDClient, ) *GetClient[Input, Output]
NewGetClient creates a new GetClient given a base client.
type UpdateClient ¶
type UpdateClient[Input any, Output any] struct { *CRUDClient }
UpdateClient is a generic wrapper for the update endpoint.
func NewUpdateClient ¶
func NewUpdateClient[Input any, Output any]( base *CRUDClient, ) *UpdateClient[Input, Output]
NewUpdateClient creates a new UpdateClient given a base client.