Documentation
¶
Index ¶
- type MediaHandler
- func (h *MediaHandler) DeleteMedia(w http.ResponseWriter, r *http.Request)
- func (h *MediaHandler) GenerateImage(w http.ResponseWriter, r *http.Request)
- func (h *MediaHandler) GetMedia(w http.ResponseWriter, r *http.Request)
- func (h *MediaHandler) GetMediaByID(w http.ResponseWriter, r *http.Request)
- func (h *MediaHandler) Upload(w http.ResponseWriter, r *http.Request)
- type MediaHandlerOption
- type MediaServiceInterface
- type RoleCapabilities
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MediaHandler ¶
type MediaHandler struct {
// contains filtered or unexported fields
}
func NewMediaHandler ¶
func NewMediaHandler( mediaService MediaServiceInterface, imageGenService media.ImageGenerationService, logger kernel.Logger, opts ...MediaHandlerOption, ) *MediaHandler
func (*MediaHandler) DeleteMedia ¶
func (h *MediaHandler) DeleteMedia(w http.ResponseWriter, r *http.Request)
func (*MediaHandler) GenerateImage ¶
func (h *MediaHandler) GenerateImage(w http.ResponseWriter, r *http.Request)
func (*MediaHandler) GetMedia ¶
func (h *MediaHandler) GetMedia(w http.ResponseWriter, r *http.Request)
GetMedia handles GET /api/v1/media (browser admin realm). Admins manage all site media; every other role is scoped to their own library so one account cannot inventory another's file paths, hashes, and original filenames. Rows come newest-first (id DESC) using opaque keyset (cursor) pagination — the SAME contract as the agent media list (bare data array + meta.pagination). It reuses the response package's cursor helpers and SuccessList/ Pagination/ListMeta types so both auth realms share one envelope.
func (*MediaHandler) GetMediaByID ¶
func (h *MediaHandler) GetMediaByID(w http.ResponseWriter, r *http.Request)
func (*MediaHandler) Upload ¶
func (h *MediaHandler) Upload(w http.ResponseWriter, r *http.Request)
type MediaHandlerOption ¶
type MediaHandlerOption func(*MediaHandler)
MediaHandlerOption configures a MediaHandler. A role service makes the media capabilities config-driven; without one every authenticated user may upload, generate, and delete media (the legacy behavior).
func WithMediaRoleService ¶
func WithMediaRoleService(rs RoleCapabilities) MediaHandlerOption
WithMediaRoleService attaches the config-driven role registry so upload, generate, and delete are gated by the caller's CanMedia capability.
type MediaServiceInterface ¶
type MediaServiceInterface interface {
Upload(ctx context.Context, req media.UploadRequest) (*media.Media, error)
ForceUpload(ctx context.Context, req media.UploadRequest) (*media.Media, error)
GenerateFromBytes(ctx context.Context, imageBytes []byte, principal kernel.Principal, altText string, originalFilename string) (*media.Media, error)
GetByID(ctx context.Context, id int) (*media.Media, error)
Delete(ctx context.Context, id int, principal kernel.Principal) error
SearchMediaByCursor(ctx context.Context, principal kernel.Principal, search string, dateFilter string, limit int, beforeID int) ([]*media.Media, error)
Count(ctx context.Context, principal kernel.Principal, search string, dateFilter string) (int, error)
}
type RoleCapabilities ¶
RoleCapabilities is the narrow role-registry seam this handler depends on. Core satisfies it with an adapter over *role.Service (which cannot be imported here); the users module implements it natively when it lands.