From 044e297413066262c54beb33e98d0e498178897b Mon Sep 17 00:00:00 2001 From: Stefan Majewsky Date: Tue, 21 Jul 2026 14:23:40 +0200 Subject: use http.MethodFoo constants where possible --- object.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'object.go') diff --git a/object.go b/object.go index 223c1a3..a09b18c 100644 --- a/object.go +++ b/object.go @@ -126,7 +126,7 @@ func (o *Object) Headers(ctx context.Context) (ObjectHeaders, error) { func (o *Object) fetchHeaders(ctx context.Context, opts *RequestOptions) (*ObjectHeaders, error) { resp, err := Request{ - Method: "HEAD", + Method: http.MethodHead, ContainerName: o.c.name, ObjectName: o.name, Options: opts, @@ -152,7 +152,7 @@ func (o *Object) fetchHeaders(ctx context.Context, opts *RequestOptions) (*Objec // A successful POST request implies Invalidate() since it may change metadata. func (o *Object) Update(ctx context.Context, headers ObjectHeaders, opts *RequestOptions) error { resp, err := Request{ - Method: "POST", + Method: http.MethodPost, ContainerName: o.c.name, ObjectName: o.name, Options: cloneRequestOptions(opts, headers.Headers), @@ -263,7 +263,7 @@ func (o *Object) Upload(ctx context.Context, content io.Reader, opts *UploadOpti } resp, err := Request{ - Method: "PUT", + Method: http.MethodPut, ContainerName: o.c.name, ObjectName: o.name, Options: ropts, @@ -415,7 +415,7 @@ func (o *Object) Delete(ctx context.Context, opts *DeleteOptions, ropts *Request } resp, err := Request{ - Method: "DELETE", + Method: http.MethodDelete, ContainerName: o.c.name, ObjectName: o.name, Options: ropts, @@ -455,7 +455,7 @@ func (o *Object) Invalidate() { // object results in undefined behavior. func (o *Object) Download(ctx context.Context, opts *RequestOptions) DownloadedObject { resp, err := Request{ - Method: "GET", + Method: http.MethodGet, ContainerName: o.c.name, ObjectName: o.name, Options: opts, @@ -641,7 +641,7 @@ func (o *Object) URL() (string, error) { // err := c.Update(ctx, hdr, nil) // // //...we can use it to generate temporary URLs. -// url := o.TempURL(ctx, key, "GET", time.Now().Add(10 * time.Minute)) +// url := o.TempURL(ctx, key, http.MethodGet, time.Now().Add(10 * time.Minute)) // resp, err := http.Get(url) // //This time, resp.StatusCode == 200 because the URL includes a token. func (o *Object) TempURL(ctx context.Context, key, method string, expires time.Time) (string, error) { -- cgit v1.3.1