mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-24 22:08:58 -05:00
git-subtree-dir: thumbnails git-subtree-mainline:ccc651a11egit-subtree-split:2ebf7b2f23
31 lines
563 B
Go
31 lines
563 B
Go
package imgsource
|
|
|
|
import (
|
|
"context"
|
|
"image"
|
|
)
|
|
|
|
type key int
|
|
|
|
const (
|
|
auth key = iota
|
|
)
|
|
|
|
// Source defines the interface for image sources
|
|
type Source interface {
|
|
Get(ctx context.Context, path string) (image.Image, error)
|
|
}
|
|
|
|
// WithAuthorization puts the authorization in the context.
|
|
func WithAuthorization(parent context.Context, authorization string) context.Context {
|
|
return context.WithValue(parent, auth, authorization)
|
|
}
|
|
|
|
func authorization(ctx context.Context) string {
|
|
val := ctx.Value(auth)
|
|
if val == nil {
|
|
return ""
|
|
}
|
|
return val.(string)
|
|
}
|