Documentation ¶
Index ¶
- func RedirectMiddleware(next webkit.Handler) webkit.Handler
- type CacheManager
- type Client
- func (c Client) Delete(ctx context.Context, path string, v any) (Response, error)
- func (c Client) Do(ctx context.Context, method, path string, body io.Reader, v any) (Response, error)
- func (c Client) DoWithRequest(_ context.Context, req *http.Request, v any) (Response, error)
- func (c Client) Get(ctx context.Context, path string, v any) (Response, error)
- func (c Client) Post(ctx context.Context, path string, in any) (Response, error)
- func (c Client) Put(ctx context.Context, path string, in any) (Response, error)
- type Collection
- type CollectionService
- func (s CollectionService) Create(ctx context.Context, collection Collection, in any) (Response, error)
- func (s CollectionService) DeleteByID(ctx context.Context, collection Collection, id int) (Response, error)
- func (s CollectionService) FindById(ctx context.Context, collection Collection, id int, out any) (Response, error)
- func (s CollectionService) FindBySlug(ctx context.Context, collection Collection, slug string, out any) (Response, error)
- func (s CollectionService) List(ctx context.Context, collection Collection, params ListParams, out any) (Response, error)
- func (s CollectionService) UpdateByID(ctx context.Context, collection Collection, id int, in any) (Response, error)
- type CreateResponse
- type Error
- type Global
- type GlobalsService
- type ListParams
- type ListResponse
- type MediaOptions
- type MediaService
- type Response
- type UpdateResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CacheManager ¶
func (*CacheManager) Clear ¶
func (c *CacheManager) Clear()
func (*CacheManager) Hmmmm ¶
func (c *CacheManager) Hmmmm()
func (*CacheManager) Middle ¶
func (c *CacheManager) Middle(next webkit.Handler) webkit.Handler
Need a way of obtaining the page contents so we can cache it after the request has been processed.
func (*CacheManager) ServeHTTP ¶
func (c *CacheManager) ServeHTTP(w http.ResponseWriter, r *http.Request)
type Client ¶
type Client struct { // Each collection is mounted using its slug value. For example, if a collection's slug is // users, all corresponding routes will be mounted on /api/users. // For more info, visit: https://payloadcms.com/docs/rest-api/overview#collections Collections CollectionService // Globals cannot be created or deleted, so there are only two REST endpoints opened: // For more info, visit: https://payloadcms.com/docs/rest-api/overview#globals Globals GlobalsService // Media is a seperate service used to upload and manage media files. // For more info, visit: https://payloadcms.com/docs/upload/overview Media MediaService // contains filtered or unexported fields }
Client represents a Payload CMS client. For more information, see https://payloadcms.com/docs/api.
func (Client) Delete ¶
Delete sends an HTTP DELETE request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred.
func (Client) Do ¶
func (c Client) Do(ctx context.Context, method, path string, body io.Reader, v any) (Response, error)
Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred.
Errors occur in the eventuality if the http.StatusCode is not 2xx.
func (Client) DoWithRequest ¶
DoWithRequest sends an API request using the provided http.Request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred.
func (Client) Get ¶
Get sends an HTTP GET request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred.
type Collection ¶
type Collection string
Collection represents a collection slug from Payload. It's defined as a string under slug within the Collection Config.
const ( // CollectionMedia defines the Payload media collection slug. CollectionMedia Collection = "media" // CollectionUsers defines the Payload users collection slug. CollectionUsers Collection = "users" )
type CollectionService ¶
type CollectionService struct {
Client *Client
}
CollectionService handles communication with the collect related methods of the Shopify API.
func (CollectionService) Create ¶
func (s CollectionService) Create(ctx context.Context, collection Collection, in any) (Response, error)
Create creates a new collection entity.
func (CollectionService) DeleteByID ¶
func (s CollectionService) DeleteByID(ctx context.Context, collection Collection, id int) (Response, error)
DeleteByID deletes a collection entity by its ID.
func (CollectionService) FindById ¶
func (s CollectionService) FindById(ctx context.Context, collection Collection, id int, out any) (Response, error)
FindById finds a collection entity by its ID.
func (CollectionService) FindBySlug ¶
func (s CollectionService) FindBySlug(ctx context.Context, collection Collection, slug string, out any) (Response, error)
FindBySlug finds a collection entity by its slug.
func (CollectionService) List ¶
func (s CollectionService) List(ctx context.Context, collection Collection, params ListParams, out any) (Response, error)
List lists all collection entities.
func (CollectionService) UpdateByID ¶
func (s CollectionService) UpdateByID(ctx context.Context, collection Collection, id int, in any) (Response, error)
UpdateByID updates a collection entity by its ID.
type CreateResponse ¶
type CreateResponse[T any] struct { Doc T `json:"doc"` Message string `json:"message"` Errors []any `json:"errors"` }
CreateResponse represents a response from the Payload CMS when a new entity is created.
type ListParams ¶
type ListParams struct { Sort string `json:"sort" url:"sort"` // Sort the returned documents by a specific field. Where map[string]any `json:"where" url:"where"` // Constrain returned documents with a where query. Limit int `json:"limit" url:"limit"` // Limit the returned documents to a certain number. Page int `json:"page" url:"page"` // Get a specific page of documents. }
ListParams represents additional query parameters for the find endpoint.
type ListResponse ¶
type ListResponse[T any] struct { Docs []T `json:"docs"` Total int `json:"total"` TotalDocs int `json:"totalDocs"` Limit int `json:"limit"` TotalPages int `json:"totalPages"` Page int `json:"page"` PagingCounter int `json:"pagingCounter"` HasPrevPage bool `json:"hasPrevPage"` HasNextPage bool `json:"hasNextPage"` PrevPage any `json:"prevPage"` NextPage any `json:"nextPage"` }
ListResponse represents a list of entities that is sent back from the Payload CMS.
type MediaOptions ¶
type MediaOptions struct { // The collection to upload the media to, defaults to "media" Collection string // If set, the file name of the media will be overridden from the file name. // Note, this will not change the file extension. FileNameOverride string }
MediaOptions represents non-required options for uploading media.
type MediaService ¶
type MediaService struct {
Client *Client
}
MediaService represents a service for managing media within Payload.
func (MediaService) Upload ¶
func (s MediaService) Upload(ctx context.Context, f *os.File, in, out any, opts MediaOptions) (Response, error)
Upload uploads a file to the media endpoint.
func (MediaService) UploadFromURL ¶
func (s MediaService) UploadFromURL(ctx context.Context, url string, in, out any, opts MediaOptions) (Response, error)
type Response ¶
Response is a PayloadAPI API response. This wraps the standard http.Response returned from Payload and provides convenient access to things like body bytes.
type UpdateResponse ¶
type UpdateResponse[T any] struct { Doc T `json:"doc"` Message string `json:"message"` Errors []any `json:"error"` }
UpdateResponse represents a response from the Payload CMS when an entity is updated.