Documentation
¶
Index ¶
- Constants
- Variables
- type API
- func (*API) Close(ctx context.Context) error
- func (api *API) DeleteInteractivesHandler(w http.ResponseWriter, r *http.Request)
- func (api *API) GetInteractive(ctx context.Context, req *http.Request) (*models.Interactive, int, error)
- func (api *API) GetInteractiveHandler(w http.ResponseWriter, r *http.Request)
- func (api *API) ListInteractivesHandler(w http.ResponseWriter, req *http.Request)
- func (api *API) PatchInteractiveHandler(w http.ResponseWriter, r *http.Request)
- func (api *API) PublishCollectionHandler(w http.ResponseWriter, r *http.Request)
- func (api *API) UpdateInteractiveHandler(w http.ResponseWriter, r *http.Request)
- func (api *API) UploadInteractivesHandler(w http.ResponseWriter, r *http.Request)
- type AuthHandler
- type FilesService
- type FormDataRequest
- type FormDataValidator
- type MongoServer
- type S3Interface
Constants ¶
View Source
const ( InteractivesCreatePermission string = "interactives:create" InteractivesReadPermission string = "interactives:read" InteractivesUpdatePermission string = "interactives:update" InteractivesDeletePermission string = "interactives:delete" )
View Source
const ( UpdateFieldKey = "interactive" FileFieldKey = "file" )
View Source
const (
MaxCollisions = 10
)
Variables ¶
View Source
var ( WantOnlyOneAttachmentWithMetadata = func(r *http.Request) error { numOfAttachments, update := len(r.MultipartForm.File), r.FormValue(UpdateFieldKey) if numOfAttachments == 1 && update != "" { return nil } return errors.New("expecting one attachment with metadata") } WantAtleastMaxOneAttachmentAndOrMetadata = func(r *http.Request) error { numOfAttachments, update := len(r.MultipartForm.File), r.FormValue(UpdateFieldKey) if numOfAttachments == 1 || update != "" { return nil } return errors.New("no attachment (max one) or metadata present") } )
View Source
var ( ErrInvalidBody = errors.New("body has invalid format") ErrCantDeletePublishedIn = errors.New("cannot delete a published interactive") )
Functions ¶
This section is empty.
Types ¶
type API ¶
func Setup ¶
func Setup(ctx context.Context, cfg *config.Config, r *mux.Router, auth authorisation.Middleware, mongoDB MongoServer, kafkaProducer kafka.IProducer, s3 S3Interface, filesService FilesService, newUUID data.Generator, newResourceID data.Generator, newSlug data.Generator, respond *responder.Responder) *API
Setup creates the API struct and its endpoints with corresponding handlers
func (*API) Close ¶
Close is called during graceful shutdown to give the API an opportunity to perform any required disposal task
func (*API) DeleteInteractivesHandler ¶
func (api *API) DeleteInteractivesHandler(w http.ResponseWriter, r *http.Request)
func (*API) GetInteractive ¶
func (*API) GetInteractiveHandler ¶
func (api *API) GetInteractiveHandler(w http.ResponseWriter, r *http.Request)
func (*API) ListInteractivesHandler ¶
func (api *API) ListInteractivesHandler(w http.ResponseWriter, req *http.Request)
func (*API) PatchInteractiveHandler ¶
func (api *API) PatchInteractiveHandler(w http.ResponseWriter, r *http.Request)
func (*API) PublishCollectionHandler ¶
func (api *API) PublishCollectionHandler(w http.ResponseWriter, r *http.Request)
dedicated publish collection as multiple interactives can be a part of a single collection
func (*API) UpdateInteractiveHandler ¶
func (api *API) UpdateInteractiveHandler(w http.ResponseWriter, r *http.Request)
update rules if published - allow only file updates if unpublished - allow both file + metadata
func (*API) UploadInteractivesHandler ¶
func (api *API) UploadInteractivesHandler(w http.ResponseWriter, r *http.Request)
type AuthHandler ¶
type AuthHandler interface {
Require(permission string, handler http.HandlerFunc) http.HandlerFunc
}
AuthHandler interface for adding auth to endpoints
type FilesService ¶
type FilesService interface {
SetCollectionID(ctx context.Context, file, collectionID string) error
Checker(ctx context.Context, state *healthcheck.CheckState) error
}
type FormDataRequest ¶
type FormDataRequest struct {
Name string
Interactive *models.Interactive
TmpFileName string
// contains filtered or unexported fields
}
type FormDataValidator ¶
type MongoServer ¶
type MongoServer interface {
Close(ctx context.Context) error
Checker(ctx context.Context, state *healthcheck.CheckState) (err error)
UpsertInteractive(ctx context.Context, id string, vis *models.Interactive) (err error)
GetInteractive(ctx context.Context, id string) (*models.Interactive, error)
ListInteractives(ctx context.Context, filter *models.Filter) ([]*models.Interactive, error)
PatchInteractive(context.Context, interactives.PatchAttribute, *models.Interactive) error
}
type S3Interface ¶
type S3Interface interface {
Upload(input *s3manager.UploadInput, options ...func(*s3manager.Uploader)) (*s3manager.UploadOutput, error)
ValidateBucket() error
Checker(ctx context.Context, state *healthcheck.CheckState) error
}
Click to show internal directories.
Click to hide internal directories.