Documentation
¶
Index ¶
- Constants
- func CompressionMiddleware(next http.Handler) http.Handler
- func GetLatestVersionObject(objects []*simplecontent.Object) *simplecontent.Object
- func RecoveryMiddleware(next http.Handler) http.Handler
- func RequestIDMiddleware(next http.Handler) http.Handler
- type AuthenticationFunc
- type ContentHandler
- func (h *ContentHandler) CreateContent(w http.ResponseWriter, r *http.Request)
- func (h *ContentHandler) CreateDerivedContent(w http.ResponseWriter, r *http.Request)
- func (h *ContentHandler) CreateObject(w http.ResponseWriter, r *http.Request)
- func (h *ContentHandler) DeleteContent(w http.ResponseWriter, r *http.Request)
- func (h *ContentHandler) GetContent(w http.ResponseWriter, r *http.Request)
- func (h *ContentHandler) GetContentDetails(w http.ResponseWriter, r *http.Request)
- func (h *ContentHandler) GetContentMetadataHandler(w http.ResponseWriter, r *http.Request)
- func (h *ContentHandler) GetContentsByIDs(w http.ResponseWriter, r *http.Request)
- func (h *ContentHandler) GetDerivedContent(w http.ResponseWriter, r *http.Request)
- func (h *ContentHandler) GetDerivedContentTree(w http.ResponseWriter, r *http.Request)
- func (h *ContentHandler) ListObjects(w http.ResponseWriter, r *http.Request)
- func (h *ContentHandler) Routes() chi.Router
- func (h *ContentHandler) SetContentMetadata(w http.ResponseWriter, r *http.Request)
- type ContentResponse
- type CreateContentRequest
- type CreateDerivedContentRequest
- type CreateDerivedContentResponse
- type CreateFileRequest
- type CreateFileResponse
- type CreateObjectRequest
- type FileInfoResponse
- type FilesHandler
- func (h *FilesHandler) CompleteUpload(w http.ResponseWriter, r *http.Request)
- func (h *FilesHandler) CreateFile(w http.ResponseWriter, r *http.Request)
- func (h *FilesHandler) GetFileInfo(w http.ResponseWriter, r *http.Request)
- func (h *FilesHandler) GetFilesByContentIDs(w http.ResponseWriter, r *http.Request)
- func (h *FilesHandler) Routes() chi.Router
- type MetricsCollector
- type Middleware
- func AuthenticationMiddleware(authFunc AuthenticationFunc) Middleware
- func BodyLoggingMiddleware(logger *log.Logger) Middleware
- func CORSMiddleware(allowedOrigins []string, allowedMethods []string, allowedHeaders []string) Middleware
- func CacheMiddleware(maxAge int) Middleware
- func LoggingMiddleware(logger *log.Logger) Middleware
- func MetricsMiddleware(collector MetricsCollector) Middleware
- func RequestSizeLimitMiddleware(maxBytes int64) Middleware
- func TimeoutMiddleware(timeout time.Duration) Middleware
- func ValidationMiddleware(validator RequestValidator) Middleware
- type MiddlewareChain
- type ObjectResponse
- type RateLimiter
- type RequestValidator
- type UpdateMetadataRequest
Constants ¶
const ( RequestIDKey contextKey = "request_id" RequestTimeKey contextKey = "request_time" UserIDKey contextKey = "user_id" TenantIDKey contextKey = "tenant_id" )
const DEFAULT_STORAGE_BACKEND = "s3-default"
Variables ¶
This section is empty.
Functions ¶
func CompressionMiddleware ¶ added in v0.2.1
CompressionMiddleware adds gzip compression for responses
func GetLatestVersionObject ¶
func GetLatestVersionObject(objects []*simplecontent.Object) *simplecontent.Object
GetLatestVersionObject returns the object with the highest version number from a slice of objects. If there are multiple objects with the same highest version, it returns the first one found.
func RecoveryMiddleware ¶ added in v0.2.1
RecoveryMiddleware recovers from panics and returns 500 error
Types ¶
type AuthenticationFunc ¶ added in v0.2.1
AuthenticationMiddleware validates authentication tokens
type ContentHandler ¶
type ContentHandler struct {
// contains filtered or unexported fields
}
ContentHandler handles HTTP requests for content using pkg/simplecontent
func NewContentHandler ¶
func NewContentHandler(service simplecontent.Service, storageService simplecontent.StorageService) *ContentHandler
NewContentHandler creates a new content handler
func (*ContentHandler) CreateContent ¶
func (h *ContentHandler) CreateContent(w http.ResponseWriter, r *http.Request)
CreateContent creates a new content
func (*ContentHandler) CreateDerivedContent ¶
func (h *ContentHandler) CreateDerivedContent(w http.ResponseWriter, r *http.Request)
CreateDerivedContent creates a new derived content from a parent content
func (*ContentHandler) CreateObject ¶
func (h *ContentHandler) CreateObject(w http.ResponseWriter, r *http.Request)
CreateObject creates a new object for a content
func (*ContentHandler) DeleteContent ¶
func (h *ContentHandler) DeleteContent(w http.ResponseWriter, r *http.Request)
DeleteContent deletes a content by ID
func (*ContentHandler) GetContent ¶
func (h *ContentHandler) GetContent(w http.ResponseWriter, r *http.Request)
GetContent retrieves a content by ID
func (*ContentHandler) GetContentDetails ¶
func (h *ContentHandler) GetContentDetails(w http.ResponseWriter, r *http.Request)
GetContentDetails retrieves detailed content information with URLs
func (*ContentHandler) GetContentMetadataHandler ¶ added in v0.2.1
func (h *ContentHandler) GetContentMetadataHandler(w http.ResponseWriter, r *http.Request)
GetContentMetadataHandler retrieves metadata for a content
func (*ContentHandler) GetContentsByIDs ¶
func (h *ContentHandler) GetContentsByIDs(w http.ResponseWriter, r *http.Request)
GetContentsByIDs retrieves multiple contents by their IDs
func (*ContentHandler) GetDerivedContent ¶ added in v0.2.1
func (h *ContentHandler) GetDerivedContent(w http.ResponseWriter, r *http.Request)
GetDerivedContent retrieves direct derived content for a parent
func (*ContentHandler) GetDerivedContentTree ¶ added in v0.2.1
func (h *ContentHandler) GetDerivedContentTree(w http.ResponseWriter, r *http.Request)
GetDerivedContentTree retrieves the entire derived content tree (recursive)
func (*ContentHandler) ListObjects ¶
func (h *ContentHandler) ListObjects(w http.ResponseWriter, r *http.Request)
ListObjects lists objects for a content Query parameters:
- latest=true: Only return the latest version object (default: true)
func (*ContentHandler) Routes ¶
func (h *ContentHandler) Routes() chi.Router
Routes returns the routes for content
func (*ContentHandler) SetContentMetadata ¶ added in v0.2.1
func (h *ContentHandler) SetContentMetadata(w http.ResponseWriter, r *http.Request)
SetContentMetadata sets metadata for a content
type ContentResponse ¶
type ContentResponse struct {
ID string `json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
OwnerID string `json:"owner_id"`
TenantID string `json:"tenant_id"`
Status string `json:"status"`
MimeType string `json:"mime_type"`
FileSize int64 `json:"file_size"`
FileName string `json:"file_name"`
DocumentType string `json:"document_type"`
DerivationType string `json:"derivation_type"`
DerivationLevel int `json:"derivation_level"`
ParentID string `json:"parent_id,omitempty"`
}
ContentResponse is the response body for a content
type CreateContentRequest ¶
type CreateContentRequest struct {
OwnerID string `json:"owner_id"`
TenantID string `json:"tenant_id"`
DocumentType string `json:"document_type"`
FileName string `json:"file_name"`
OwnerType string `json:"owner_type"`
MimeType string `json:"mime_type"`
FileSize int64 `json:"file_size"`
Status string `json:"status,omitempty"` // Optional initial status (defaults to "created")
}
CreateContentRequest is the request body for creating a content
type CreateDerivedContentRequest ¶
type CreateDerivedContentRequest struct {
DerivedContentID uuid.UUID `json:"derived_content_id"`
DerivationType string `json:"derivation_type"`
DerivationParams map[string]interface{} `json:"derivation_params"`
ProcessingMetadata map[string]interface{} `json:"processing_metadata"`
OwnerID string `json:"owner_id"`
TenantID string `json:"tenant_id"`
Status string `json:"status,omitempty"` // Optional initial status (defaults to "created")
}
CreateDerivedContentRequest is the request body for creating derived content
type CreateDerivedContentResponse ¶
type CreateDerivedContentResponse struct {
ParentContentID string `json:"parent_content_id"`
DerivedContentID string `json:"derived_content_id"`
DerivationType string `json:"derivation_type"`
}
CreateDerivedContentResponse is the response body for derived content creation
type CreateFileRequest ¶
type CreateFileRequest struct {
OwnerID string `json:"owner_id"`
OwnerType string `json:"owner_type"`
TenantID string `json:"tenant_id"`
FileName string `json:"file_name"`
MimeType string `json:"mime_type,omitempty"`
FileSize int64 `json:"file_size,omitempty"`
DocumentType string `json:"document_type,omitempty"`
StorageBackendName string `json:"storage_backend_name,omitempty"`
}
CreateFileRequest represents the request to create a new file
type CreateFileResponse ¶
type CreateFileResponse struct {
ContentID string `json:"content_id"`
ObjectID string `json:"object_id"`
UploadURL string `json:"upload_url"`
CreatedAt time.Time `json:"created_at"`
Status string `json:"status"`
}
CreateFileResponse represents the response after creating a file
type CreateObjectRequest ¶
type CreateObjectRequest struct {
StorageBackendName string `json:"storage_backend_name"`
Version int `json:"version"`
ObjectKey string `json:"object_key"`
MimeType string `json:"mime_type"`
FileSize int64 `json:"file_size"`
FileName string `json:"file_name"`
}
CreateObjectRequest is the request body for creating an object
type FileInfoResponse ¶
type FileInfoResponse struct {
ContentID string `json:"content_id"`
FileName string `json:"file_name"`
PreviewURL string `json:"preview_url"`
DownloadURL string `json:"download_url"`
Metadata map[string]interface{} `json:"metadata"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Status string `json:"status"`
MimeType string `json:"mime_type"`
FileSize int64 `json:"file_size"`
OwnerID string `json:"owner_id"`
OwnerType string `json:"owner_type"`
TenantID string `json:"tenant_id"`
}
FileInfoResponse represents file information including URLs
type FilesHandler ¶
type FilesHandler struct {
// contains filtered or unexported fields
}
FilesHandler handles file upload and management API endpoints using pkg/simplecontent
func NewFilesHandler ¶
func NewFilesHandler(service simplecontent.Service, storageService simplecontent.StorageService) *FilesHandler
func (*FilesHandler) CompleteUpload ¶
func (h *FilesHandler) CompleteUpload(w http.ResponseWriter, r *http.Request)
CompleteUpload marks a client-side upload as complete
func (*FilesHandler) CreateFile ¶
func (h *FilesHandler) CreateFile(w http.ResponseWriter, r *http.Request)
CreateFile creates a new content and returns upload URL
func (*FilesHandler) GetFileInfo ¶
func (h *FilesHandler) GetFileInfo(w http.ResponseWriter, r *http.Request)
GetFileInfo returns file information including preview and download URLs
func (*FilesHandler) GetFilesByContentIDs ¶
func (h *FilesHandler) GetFilesByContentIDs(w http.ResponseWriter, r *http.Request)
GetFilesByContentIDs retrieves multiple files by their IDs
func (*FilesHandler) Routes ¶
func (h *FilesHandler) Routes() chi.Router
Routes returns the router for files endpoints
type MetricsCollector ¶ added in v0.2.1
type MetricsCollector interface {
RecordRequest(method, path string, statusCode int, duration time.Duration, size int64)
}
MetricsMiddleware tracks request metrics
type Middleware ¶ added in v0.2.1
Middleware is a function that wraps an http.Handler
func AuthenticationMiddleware ¶ added in v0.2.1
func AuthenticationMiddleware(authFunc AuthenticationFunc) Middleware
func BodyLoggingMiddleware ¶ added in v0.2.1
func BodyLoggingMiddleware(logger *log.Logger) Middleware
BodyLoggingMiddleware logs request and response bodies (for debugging)
func CORSMiddleware ¶ added in v0.2.1
func CORSMiddleware(allowedOrigins []string, allowedMethods []string, allowedHeaders []string) Middleware
CORSMiddleware handles CORS headers
func CacheMiddleware ¶ added in v0.2.1
func CacheMiddleware(maxAge int) Middleware
CacheMiddleware adds cache control headers
func LoggingMiddleware ¶ added in v0.2.1
func LoggingMiddleware(logger *log.Logger) Middleware
LoggingMiddleware logs HTTP requests and responses
func MetricsMiddleware ¶ added in v0.2.1
func MetricsMiddleware(collector MetricsCollector) Middleware
func RequestSizeLimitMiddleware ¶ added in v0.2.1
func RequestSizeLimitMiddleware(maxBytes int64) Middleware
RequestSizeLimitMiddleware limits the size of request bodies
func TimeoutMiddleware ¶ added in v0.2.1
func TimeoutMiddleware(timeout time.Duration) Middleware
TimeoutMiddleware adds a timeout to request processing
func ValidationMiddleware ¶ added in v0.2.1
func ValidationMiddleware(validator RequestValidator) Middleware
type MiddlewareChain ¶ added in v0.2.1
type MiddlewareChain struct {
// contains filtered or unexported fields
}
MiddlewareChain represents a chain of middleware functions
func NewMiddlewareChain ¶ added in v0.2.1
func NewMiddlewareChain(middlewares ...Middleware) *MiddlewareChain
NewMiddlewareChain creates a new middleware chain
func (*MiddlewareChain) Then ¶ added in v0.2.1
func (c *MiddlewareChain) Then(m Middleware) *MiddlewareChain
Then adds middleware to the chain
type ObjectResponse ¶
type ObjectResponse struct {
ID string `json:"id"`
ContentID string `json:"content_id"`
StorageBackendName string `json:"storage_backend_name"`
Version int `json:"version"`
ObjectKey string `json:"object_key"`
Status string `json:"status"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
UploadURL string `json:"upload_url"`
}
ObjectResponse is the response body for an object
type RateLimiter ¶ added in v0.2.1
type RateLimiter struct {
// contains filtered or unexported fields
}
RateLimitMiddleware implements simple rate limiting (token bucket)
func NewRateLimiter ¶ added in v0.2.1
func NewRateLimiter(requestsPerMinute int) *RateLimiter
func (*RateLimiter) Middleware ¶ added in v0.2.1
func (rl *RateLimiter) Middleware(next http.Handler) http.Handler
type RequestValidator ¶ added in v0.2.1
ValidationMiddleware validates request bodies against a schema
type UpdateMetadataRequest ¶
type UpdateMetadataRequest struct {
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Tags []string `json:"tags,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
UpdateMetadataRequest represents the request to update file metadata