use http consts for request methods

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2022-11-02 23:31:23 +01:00
parent 7f9f86c411
commit f9ccd2c6ea
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C
33 changed files with 211 additions and 211 deletions

View file

@ -38,7 +38,7 @@ func (hbu *httpBlobUpload) handleErrorResponse(resp *http.Response) error {
}
func (hbu *httpBlobUpload) ReadFrom(r io.Reader) (n int64, err error) {
req, err := http.NewRequestWithContext(hbu.ctx, "PATCH", hbu.location, ioutil.NopCloser(r))
req, err := http.NewRequestWithContext(hbu.ctx, http.MethodPatch, hbu.location, ioutil.NopCloser(r))
if err != nil {
return 0, err
}
@ -71,7 +71,7 @@ func (hbu *httpBlobUpload) ReadFrom(r io.Reader) (n int64, err error) {
}
func (hbu *httpBlobUpload) Write(p []byte) (n int, err error) {
req, err := http.NewRequestWithContext(hbu.ctx, "PATCH", hbu.location, bytes.NewReader(p))
req, err := http.NewRequestWithContext(hbu.ctx, http.MethodPatch, hbu.location, bytes.NewReader(p))
if err != nil {
return 0, err
}
@ -119,7 +119,7 @@ func (hbu *httpBlobUpload) StartedAt() time.Time {
func (hbu *httpBlobUpload) Commit(ctx context.Context, desc distribution.Descriptor) (distribution.Descriptor, error) {
// TODO(dmcgowan): Check if already finished, if so just fetch
req, err := http.NewRequestWithContext(hbu.ctx, "PUT", hbu.location, nil)
req, err := http.NewRequestWithContext(hbu.ctx, http.MethodPut, hbu.location, nil)
if err != nil {
return distribution.Descriptor{}, err
}
@ -142,7 +142,7 @@ func (hbu *httpBlobUpload) Commit(ctx context.Context, desc distribution.Descrip
}
func (hbu *httpBlobUpload) Cancel(ctx context.Context) error {
req, err := http.NewRequestWithContext(hbu.ctx, "DELETE", hbu.location, nil)
req, err := http.NewRequestWithContext(hbu.ctx, http.MethodDelete, hbu.location, nil)
if err != nil {
return err
}