Documentation
¶
Overview ¶
Package handler /*
## License This project is licensed under the APACHE Licence. Refer to https://github.com/mstgnz/go-minio-cdn/blob/main/LICENSE for more information.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ArchiveHandler ¶ added in v1.10.0
type ArchiveHandler interface {
ArchiveObjects(w http.ResponseWriter, r *http.Request) error
}
ArchiveHandler serves the on-demand tiering endpoint.
func NewArchiveHandler ¶ added in v1.10.0
func NewArchiveHandler(tiering *service.Tiering) ArchiveHandler
type ArchiveRequest ¶ added in v1.10.0
type ArchiveRequest struct {
Bucket string `json:"bucket"`
// Files accepts either an object key ("2026/photo.jpg") or a full CDN URL
// ("https://cdn.example.com/bucket/2026/photo.jpg"). Callers usually store
// the URL this service handed them at upload time, so requiring them to take
// it apart again would be busywork with a chance of getting it wrong.
Files []string `json:"files" validate:"required,min=1"`
// Evict controls whether the local copy is removed once the archive is
// verified to hold the object. A pointer so that omitting the field means
// true: the point of the endpoint is to free disk, and a caller that wants
// only to take a copy has to say so.
Evict *bool `json:"evict"`
}
ArchiveRequest asks for specific objects to be moved to cold storage.
This exists because age is not a usable signal on every deployment. Objects migrated into a CDN from the applications that used to hold them carry the migration date, not the date the content was created, so a scheduled sweep over "older than N days" would either delete everything or nothing. The application that owns the content is the only party that knows when it stops needing to be served from local disk, so it is the one that decides.
type AwsHandler ¶
type AwsHandler interface {
GlacierVaultList(w http.ResponseWriter, r *http.Request) error
BucketList(w http.ResponseWriter, r *http.Request) error
BucketExists(w http.ResponseWriter, r *http.Request) error
// New glacier methods
GlacierInitiateRetrieval(w http.ResponseWriter, r *http.Request) error
GlacierListJobs(w http.ResponseWriter, r *http.Request) error
GlacierDownloadArchive(w http.ResponseWriter, r *http.Request) error
GlacierJobStatus(w http.ResponseWriter, r *http.Request) error
GlacierInventoryRetrieval(w http.ResponseWriter, r *http.Request) error
// New async download methods
GlacierInitiateAsyncDownload(w http.ResponseWriter, r *http.Request) error
GlacierCheckDownloadStatus(w http.ResponseWriter, r *http.Request) error
}
func NewAwsHandler ¶
func NewAwsHandler(awsService service.AwsService) AwsHandler
type BatchDeleteRequest ¶ added in v1.5.0
type BatchDeleteRequest struct {
Bucket string `json:"bucket"`
Files []string `json:"files" validate:"required,min=1"`
AWSDelete bool `json:"aws_delete"`
}
BatchDeleteRequest represents the request body for batch deletions. Bucket is optional for the same reason as UploadUrlRequest.Bucket.
type BatchUploadRequest ¶ added in v1.5.0
type BatchUploadRequest struct {
Bucket string `json:"bucket" validate:"required"`
Path string `json:"path"`
Files []string `json:"files" validate:"required,min=1"`
// Deprecated: has no effect. See UploadUrlRequest.AWSUpload.
AWSUpload bool `json:"aws_upload"`
}
BatchUploadRequest represents the request body for batch uploads
type DownloadJob ¶ added in v1.6.0
type DownloadJob struct {
ID string `json:"id"`
VaultName string `json:"vaultName"`
JobID string `json:"jobId"`
TargetBucket string `json:"targetBucket,omitempty"`
TargetPath string `json:"targetPath"`
Status string `json:"status"` // pending, processing, completed, failed
Error string `json:"error,omitempty"`
StartTime time.Time `json:"startTime"`
EndTime *time.Time `json:"endTime,omitempty"`
DownloadType string `json:"downloadType"` // minio, local, stream
}
DownloadJob represents an async download job
type HealthChecker ¶ added in v1.5.0
type HealthChecker struct {
// contains filtered or unexported fields
}
func NewHealthChecker ¶ added in v1.5.0
func NewHealthChecker(minioClient *minio.Client, awsService service.AwsService, cache service.CacheService) *HealthChecker
func (*HealthChecker) HealthCheck ¶ added in v1.5.0
func (h *HealthChecker) HealthCheck(w http.ResponseWriter, r *http.Request) error
HealthCheck handles health check requests
type Image ¶
type Image interface {
GetImage(w http.ResponseWriter, r *http.Request) error
UploadImage(w http.ResponseWriter, r *http.Request) error
DeleteImage(w http.ResponseWriter, r *http.Request) error
ResizeImage(w http.ResponseWriter, r *http.Request) error
UploadWithUrl(w http.ResponseWriter, r *http.Request) error
BatchUpload(w http.ResponseWriter, r *http.Request) error
BatchDelete(w http.ResponseWriter, r *http.Request) error
}
type ImageProcessRequest ¶ added in v1.5.0
type ImageProcessRequest struct {
File []byte
Width uint
Height uint
ContentType string
Filename string
// Result holds the resized bytes once processImage has run. It is written by
// the worker goroutine and read by whoever submitted the job, which is safe
// only because the submitter waits on the job's response channel first.
Result []byte
}
ImageProcessRequest represents an image processing request
type MinioHandler ¶ added in v1.2.1
type MinioHandler interface {
BucketList(w http.ResponseWriter, r *http.Request) error
BucketExists(w http.ResponseWriter, r *http.Request) error
CreateBucket(w http.ResponseWriter, r *http.Request) error
RemoveBucket(w http.ResponseWriter, r *http.Request) error
}
func NewMinioHandler ¶ added in v1.2.1
func NewMinioHandler(minioClient *minio.Client) MinioHandler
type MonitoringStats ¶ added in v1.5.0
type MonitoringStats struct {
Timestamp time.Time `json:"timestamp"`
ActiveUploads int `json:"active_uploads"`
UploadSpeed float64 `json:"upload_speed"`
CacheHitRate float64 `json:"cache_hit_rate"`
CPUUsage float64 `json:"cpu_usage"`
MemoryUsage float64 `json:"memory_usage"`
DiskUsage map[string]int64 `json:"disk_usage"`
Errors []string `json:"errors"`
}
type UploadUrlRequest ¶ added in v1.5.0
type UploadUrlRequest struct {
Path string `json:"path"`
Bucket string `json:"bucket"`
URL string `json:"url" validate:"required,url"`
// AWSUpload is accepted and ignored.
//
// Archiving used to be requested per upload through this field. It is now a
// property of the deployment: on when AWS credentials are configured, off
// when they are not. The field stays so that clients still sending it keep
// working rather than failing validation; it will be removed in a later
// major version.
//
// Deprecated: has no effect.
AWSUpload bool `json:"aws_upload"`
Optimize bool `json:"optimize"`
}
UploadUrlRequest represents the request body for URL-based uploads.
Bucket carries no "required" tag: a bucket-scoped token already names its bucket, so the field is optional for those callers. Emptiness is enforced after the token and the request have been reconciled by resolveBucket.
type WebSocketHandler ¶ added in v1.5.0
type WebSocketHandler interface {
HandleWebSocket(w http.ResponseWriter, r *http.Request) error
MonitorStats(w http.ResponseWriter, r *http.Request) error
}
func NewWebSocketHandler ¶ added in v1.5.0
func NewWebSocketHandler(stats *service.StatsService) WebSocketHandler