Lint and documentation fixes

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
This commit is contained in:
Derek McGowan 2015-05-15 17:37:32 -07:00
parent 2874454224
commit 006ddd8283
3 changed files with 10 additions and 1 deletions

View file

@ -152,7 +152,7 @@ func TestUploadReadFrom(t *testing.T) {
t.Fatalf("Expected error when not found") t.Fatalf("Expected error when not found")
} }
if err != distribution.ErrBlobUploadUnknown { if err != distribution.ErrBlobUploadUnknown {
t.Fatalf("Wrong error thrown: %s, expected", err, distribution.ErrBlobUploadUnknown) t.Fatalf("Wrong error thrown: %s, expected %s", err, distribution.ErrBlobUploadUnknown)
} }
// 400 valid json // 400 valid json

View file

@ -13,6 +13,9 @@ import (
"github.com/docker/distribution" "github.com/docker/distribution"
) )
// NewHTTPReadSeeker handles reading from an HTTP endpoint using a GET
// request. When seeking and starting a read from a non-zero offset
// the a "Range" header will be added which sets the offset.
func NewHTTPReadSeeker(client *http.Client, url string, size int64) distribution.ReadSeekCloser { func NewHTTPReadSeeker(client *http.Client, url string, size int64) distribution.ReadSeekCloser {
return &httpReadSeeker{ return &httpReadSeeker{
client: client, client: client,

View file

@ -6,12 +6,16 @@ import (
"sync" "sync"
) )
// RequestModifier represents an object which will do an inplace
// modification of an HTTP request.
type RequestModifier interface { type RequestModifier interface {
ModifyRequest(*http.Request) error ModifyRequest(*http.Request) error
} }
type headerModifier http.Header type headerModifier http.Header
// NewHeaderRequestModifier returns a new RequestModifier which will
// add the given headers to a request.
func NewHeaderRequestModifier(header http.Header) RequestModifier { func NewHeaderRequestModifier(header http.Header) RequestModifier {
return headerModifier(header) return headerModifier(header)
} }
@ -24,6 +28,8 @@ func (h headerModifier) ModifyRequest(req *http.Request) error {
return nil return nil
} }
// NewTransport creates a new transport which will apply modifiers to
// the request on a RoundTrip call.
func NewTransport(base http.RoundTripper, modifiers ...RequestModifier) http.RoundTripper { func NewTransport(base http.RoundTripper, modifiers ...RequestModifier) http.RoundTripper {
return &transport{ return &transport{
Modifiers: modifiers, Modifiers: modifiers,