Files
QSfera/Server/services/thumbnails/pkg/thumbnail/imgsource/imgsource.go
T
Курнат Андрей 7135199f23
Server / deployment-config (push) Successful in 59s
Android / test-and-build (push) Failing after 1m14s
Server / vulnerability-scan (push) Failing after 8m54s
Make photo library offline-first and fix video thumbnails
2026-07-19 21:01:35 +03:00

43 lines
999 B
Go

package imgsource
import (
"context"
"io"
)
type key int
const (
auth key = iota
video
)
// Source defines the interface for image sources
type Source interface {
Get(ctx context.Context, path string) (io.ReadCloser, error)
}
// ContextSetVideoSource selects the separately bounded video input limit.
func ContextSetVideoSource(parent context.Context, isVideo bool) context.Context {
return context.WithValue(parent, video, isVideo)
}
func contextIsVideoSource(ctx context.Context) bool {
value, _ := ctx.Value(video).(bool)
return value
}
// ContextSetAuthorization puts the authorization in the context.
func ContextSetAuthorization(parent context.Context, authorization string) context.Context {
return context.WithValue(parent, auth, authorization)
}
// ContextGetAuthorization gets the authorization from the context.
func ContextGetAuthorization(ctx context.Context) (string, bool) {
val := ctx.Value(auth)
if val == nil {
return "", false
}
return val.(string), true
}