forked from TrueCloudLab/distribution
Adds support for content redirects for layer downloads
Includes a delegate implementation which redirects to the URL generated by the storagedriver, and a cloudfront implementation. Satisfies proposal #49
This commit is contained in:
parent
c02f1a5507
commit
b11d549fd0
2 changed files with 18 additions and 0 deletions
12
docs/app.go
12
docs/app.go
|
@ -31,6 +31,8 @@ type App struct {
|
|||
|
||||
tokenProvider tokenProvider
|
||||
|
||||
layerHandler storage.LayerHandler
|
||||
|
||||
accessController auth.AccessController
|
||||
}
|
||||
|
||||
|
@ -76,6 +78,16 @@ func NewApp(configuration configuration.Configuration) *App {
|
|||
app.accessController = accessController
|
||||
}
|
||||
|
||||
layerHandlerType := configuration.HTTP.LayerHandler.Type()
|
||||
|
||||
if layerHandlerType != "" {
|
||||
lh, err := storage.GetLayerHandler(layerHandlerType, configuration.HTTP.LayerHandler.Parameters(), driver)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("unable to configure layer handler (%s): %v", layerHandlerType, err))
|
||||
}
|
||||
app.layerHandler = lh
|
||||
}
|
||||
|
||||
return app
|
||||
}
|
||||
|
||||
|
|
|
@ -58,5 +58,11 @@ func (lh *layerHandler) GetLayer(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
defer layer.Close()
|
||||
|
||||
handler, err := lh.layerHandler.Resolve(layer)
|
||||
if handler != nil {
|
||||
handler.ServeHTTP(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
http.ServeContent(w, r, layer.Digest().String(), layer.CreatedAt(), layer)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue