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
12
docs/app.go
12
docs/app.go
@ -31,6 +31,8 @@ type App struct {
|
|||||||
|
|
||||||
tokenProvider tokenProvider
|
tokenProvider tokenProvider
|
||||||
|
|
||||||
|
layerHandler storage.LayerHandler
|
||||||
|
|
||||||
accessController auth.AccessController
|
accessController auth.AccessController
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,6 +78,16 @@ func NewApp(configuration configuration.Configuration) *App {
|
|||||||
app.accessController = accessController
|
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
|
return app
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,5 +58,11 @@ func (lh *layerHandler) GetLayer(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
defer layer.Close()
|
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)
|
http.ServeContent(w, r, layer.Digest().String(), layer.CreatedAt(), layer)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user