package decorator
import "github.com/docker/distribution/storage/decorator"
Index ¶
- func DecorateRegistry(registry storage.Registry, decorator Decorator) storage.Registry
- type Decorator
- type Func
Functions ¶
func DecorateRegistry ¶
DecorateRegistry the provided registry with decorator. Registries may be decorated multiple times.
Types ¶
type Decorator ¶
type Decorator interface {
Decorate(v interface{}) interface{}
}
Decorator provides an interface for intercepting object creation within a registry. The single method accepts an registry storage object, such as a Layer, optionally replacing it upon with an alternative object or a wrapper.
For example, if one wants to intercept the instantiation of a layer, an implementation might be as follows:
func (md *DecoratorImplementation) Decorate(v interface{}) interface{} { switch v := v.(type) { case Layer: return wrapLayer(v) } // Make sure to return the object or nil if the decorator doesn't require // replacement. return v }
Such a decorator can be used to intercept calls to support implementing complex features outside of the storage package.
type Func ¶
type Func func(v interface{}) interface{}
Func provides a shortcut handler for decorators that only need a function. Use is similar to http.HandlerFunc.
func (Func) Decorate ¶
func (df Func) Decorate(v interface{}) interface{}
Decorate allows DecoratorFunc to implement the Decorator interface.
Source Files ¶
- Version
- v2.0.0-alpha.1+incompatible
- Published
- Jan 28, 2015
- Platform
- js/wasm
- Imports
- 2 packages
- Last checked
- 4 minutes ago –
Tools for package owners.