diff options
| author | Stefan Majewsky <majewsky@gmx.net> | 2026-04-19 00:53:33 +0200 |
|---|---|---|
| committer | Stefan Majewsky <majewsky@gmx.net> | 2026-04-19 01:01:52 +0200 |
| commit | 587ac99d26a026c4441ce224f52105d2dbd3751b (patch) | |
| tree | 83b8d130d03c958e410870e9705204fc3661eb7d /object.go | |
| parent | 23429646da1d07d6a8632263a167f167d9971f35 (diff) | |
| download | go-schwift-587ac99d26a026c4441ce224f52105d2dbd3751b.tar.gz | |
run `go fix ./...`
Diffstat (limited to 'object.go')
| -rw-r--r-- | object.go | 15 |
1 files changed, 3 insertions, 12 deletions
@@ -32,6 +32,7 @@ import ( "io" "net/http" "net/url" + "slices" "strings" "time" ) @@ -617,16 +618,6 @@ func (o *Object) URL() (string, error) { }.URL(o.c.a.backend, nil) } -// Returns true if string is contained in slice -func contains(s []string, e string) bool { - for _, a := range s { - if a == e { - return true - } - } - return false -} - // TempURL is like Object.URL, but includes a token with a limited lifetime (as // specified by the `expires` argument) that permits anonymous access to this // object using the given HTTP method. This works only when the tempurl @@ -671,9 +662,9 @@ func (o *Object) TempURL(ctx context.Context, key, method string, expires time.T var mac hash.Hash switch { - case contains(allowedDigest, "sha256"): + case slices.Contains(allowedDigest, "sha256"): mac = hmac.New(sha256.New, []byte(key)) - case contains(allowedDigest, "sha1"): + case slices.Contains(allowedDigest, "sha1"): mac = hmac.New(sha1.New, []byte(key)) default: return "", fmt.Errorf("schwift supports sha1 and sha256 digests but the Swift server only supports: %s", strings.Join(allowedDigest, ", ")) |
