Skip to content

Commit

Permalink
asd
Browse files Browse the repository at this point in the history
  • Loading branch information
dbarrosop committed Feb 1, 2024
1 parent e49d50e commit 9c04d19
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions client/delete_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ func (c *Client) DeleteFile(
ctx context.Context,
fileID string,
) error {
req, err := http.NewRequestWithContext(ctx, "DELETE", c.baseURL+"/files/"+fileID, nil)
req, err := http.NewRequestWithContext(ctx, "DELETE", c.baseURL+"/files/"+fileID, nil) //nolint:goconst
if err != nil {
return fmt.Errorf("problem creating request: %w", err)
}
req.Header.Set("Authorization", "Bearer "+c.jwt)
req.Header.Set("Authorization", "Bearer "+c.jwt) //nolint:goconst

resp, err := c.httpClient.Do(req)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions client/get_file_information.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,24 +93,24 @@ func WithIfUnmodifiedSince(modifiedSince string) GetFileInformationOpt {
func WithImageSize(newSizeX, newSizeY int) GetFileInformationOpt {
return func(req *http.Request) {
q := req.URL.Query()
q.Add("w", fmt.Sprintf("%d", newSizeX))
q.Add("h", fmt.Sprintf("%d", newSizeY))
q.Add("w", strconv.Itoa(newSizeX))
q.Add("h", strconv.Itoa(newSizeY))
req.URL.RawQuery = q.Encode()
}
}

func WithImageQuality(quality int) GetFileInformationOpt {
return func(req *http.Request) {
q := req.URL.Query()
q.Add("q", fmt.Sprintf("%d", quality))
q.Add("q", strconv.Itoa(quality))
req.URL.RawQuery = q.Encode()
}
}

func WithImageBlur(blur int) GetFileInformationOpt {
return func(req *http.Request) {
q := req.URL.Query()
q.Add("b", fmt.Sprintf("%d", blur))
q.Add("b", strconv.Itoa(blur))
req.URL.RawQuery = q.Encode()
}
}
Expand Down
3 changes: 2 additions & 1 deletion controller/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"io"
"net/http"
"net/url"
"strconv"
"time"

"github.com/gin-gonic/gin"
Expand Down Expand Up @@ -69,7 +70,7 @@ func (r *FileResponse) Write(ctx *gin.Context) {

if r.statusCode != http.StatusNotModified {
// https://www.rfc-editor.org/rfc/rfc7232#section-4.1
ctx.Header("Content-Length", fmt.Sprintf("%d", r.contentLength))
ctx.Header("Content-Length", strconv.FormatInt(r.contentLength, 10))
ctx.Header("Content-Type", r.contentType)
ctx.Header("Surrogate-Key", r.fileID)
ctx.Header("Last-modified", r.lastModified)
Expand Down
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions image/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package image_test

import (
"crypto/sha256"
"fmt"
"encoding/hex"
"io"
"os"
"testing"
Expand Down Expand Up @@ -84,7 +84,7 @@ func TestManipulate(t *testing.T) {
t.Fatal(err)
}

got := fmt.Sprintf("%x", hasher.Sum(nil))
got := hex.EncodeToString(hasher.Sum(nil))
if !cmp.Equal(got, tc.sum) {
t.Error(cmp.Diff(got, tc.sum))
}
Expand Down

0 comments on commit 9c04d19

Please sign in to comment.