Documentation ¶
Overview ¶
This package implements most commonly used endpoint logic in RFC7644.
The services defined in this package are the entry point of this module. They should be called by client HTTP handler implementations to perform the heavy lifting.
Index ¶
- type Create
- type CreateRequest
- type CreateResponse
- type Delete
- type DeleteRequest
- type DeleteResponse
- type Get
- type GetRequest
- type GetResponse
- type Patch
- type PatchOperation
- type PatchPayload
- type PatchRequest
- type PatchResponse
- type Query
- type QueryRequest
- type QueryResponse
- type Replace
- type ReplaceRequest
- type ReplaceResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Create ¶
type Create interface {
Do(ctx context.Context, req *CreateRequest) (resp *CreateResponse, err error)
}
Create resource service
func CreateService ¶
func CreateService(resourceType *spec.ResourceType, database db.DB, filters []filter.ByResource) Create
Create returns a create resource service.
type CreateRequest ¶
type CreateRequest struct {
PayloadSource io.Reader // reader source to read resource payload from
}
Create resource request
type CreateResponse ¶
Create resource response
type Delete ¶
type Delete interface {
Do(ctx context.Context, req *DeleteRequest) (resp *DeleteResponse, err error)
}
Delete resource service
func DeleteService ¶
func DeleteService(config *spec.ServiceProviderConfig, database db.DB) Delete
DeleteService returns a delete resource service
type DeleteRequest ¶
type DeleteRequest struct { ResourceID string // id of the resource to be deleted MatchCriteria func(resource *prop.Resource) bool // extra criteria the resource has to meet in order to be deleted }
Delete resource request
type DeleteResponse ¶
Delete resource response
type Get ¶
type Get interface {
Do(ctx context.Context, req *GetRequest) (resp *GetResponse, err error)
}
Get resource resource
type GetRequest ¶
type GetRequest struct { ResourceID string // id of the resource to get Projection *crud.Projection // field projection to be considered when fetching resource }
Get resource request
type GetResponse ¶
Get resource response
type Patch ¶
type Patch interface {
Do(ctx context.Context, req *PatchRequest) (resp *PatchResponse, err error)
}
Patch resource service
func PatchService ¶
func PatchService( config *spec.ServiceProviderConfig, database db.DB, preFilters []filter.ByResource, postFilters []filter.ByResource, ) Patch
PatchService returns a patch resource service. preFilters will run after resource fetched from database and before resource is patched. postFilters will run after resource has been patched and before resource is saved back to database.
type PatchOperation ¶
type PatchOperation struct { Op string `json:"op"` Path string `json:"path"` Value json.RawMessage `json:"value"` }
Patch operation definition
func (*PatchOperation) ParseValue ¶
func (o *PatchOperation) ParseValue(resource *prop.Resource) (interface{}, error)
type PatchPayload ¶
type PatchPayload struct { Schemas []string `json:"schemas"` Operations []PatchOperation `json:"Operations"` }
Patch payload definition
func (*PatchPayload) Validate ¶
func (p *PatchPayload) Validate() error
type PatchRequest ¶
type PatchRequest struct { ResourceID string // id of the resource to patch MatchCriteria func(resource *prop.Resource) bool // extra criteria to meet for the resource to be patched PayloadSource io.Reader // source to read the patch payload from }
Patch resource request
type PatchResponse ¶
type PatchResponse struct { Patched bool // true if the resource was patched; false if the resource was not patched but there was no error Ref *prop.Resource // reference resource (the before state) Resource *prop.Resource // patched resource (the after state) }
Patch resource response
type Query ¶
type Query interface {
Do(ctx context.Context, req *QueryRequest) (resp *QueryResponse, err error)
}
Query resource service
func QueryService ¶
func QueryService(config *spec.ServiceProviderConfig, database db.DB) Query
QueryService returns a query resource service. This service is only capable of performing querying on a single type of resource. This does not handle root query.
type QueryRequest ¶
type QueryRequest struct { Filter string Sort *crud.Sort Pagination *crud.Pagination Projection *crud.Projection }
Query resource request
func (*QueryRequest) ValidateAndDefault ¶
func (q *QueryRequest) ValidateAndDefault() error
type QueryResponse ¶
type QueryResponse struct { TotalResults int StartIndex int ItemsPerPage int Resources []json.Serializable Projection *crud.Projection // included so that caller may render properly }
Query resource response
type Replace ¶
type Replace interface {
Do(ctx context.Context, req *ReplaceRequest) (resp *ReplaceResponse, err error)
}
Replace resource service
func ReplaceService ¶
func ReplaceService( config *spec.ServiceProviderConfig, resourceType *spec.ResourceType, database db.DB, filters []filter.ByResource, ) Replace
ReplaceService returns a replace service.