Skip to content

Commit

Permalink
refactor: Using fmt sprintf directly from path
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Boutour <[email protected]>
  • Loading branch information
ViBiOh committed Sep 6, 2022
1 parent 438be7e commit 17d9145
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions pkg/thumbnail/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ func (a App) requestVith(ctx context.Context, item absto.Item, scale uint64) (*h
a.increaseMetric(itemType.String(), "request")

if a.directAccess {
return a.vithRequest.Method(http.MethodGet).Path(fmt.Sprintf("%s?type=%s&scale=%d&output=%s", item.Pathname, itemType, scale, outputName)).Send(ctx, nil)
return a.vithRequest.Method(http.MethodGet).Path("%s?type=%s&scale=%d&output=%s", item.Pathname, itemType, scale, outputName).Send(ctx, nil)
}

return provider.SendLargeFile(ctx, a.storageApp, item, a.vithRequest.Method(http.MethodPost).Path(fmt.Sprintf("?type=%s&scale=%d", itemType, scale)))
return provider.SendLargeFile(ctx, a.storageApp, item, a.vithRequest.Method(http.MethodPost).Path("?type=%s&scale=%d", itemType, scale))
}
8 changes: 4 additions & 4 deletions pkg/thumbnail/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (a App) shouldGenerateStream(ctx context.Context, item absto.Item) (bool, e

a.increaseMetric("stream", "bitrate")

resp, err := a.vithRequest.Method(http.MethodHead).Path(fmt.Sprintf("%s?type=%s", item.Pathname, typeOfItem(item))).Send(ctx, nil)
resp, err := a.vithRequest.Method(http.MethodHead).Path("%s?type=%s", item.Pathname, typeOfItem(item)).Send(ctx, nil)
if err != nil {
a.increaseMetric("stream", "error")
return false, fmt.Errorf("retrieve metadata: %w", err)
Expand Down Expand Up @@ -85,20 +85,20 @@ func (a App) generateStream(ctx context.Context, item absto.Item) error {

a.increaseMetric("stream", "request")

resp, err := a.vithRequest.Method(http.MethodPut).Path(fmt.Sprintf("%s?output=%s", input, url.QueryEscape(output))).Send(ctx, nil)
resp, err := a.vithRequest.Method(http.MethodPut).Path("%s?output=%s", input, url.QueryEscape(output)).Send(ctx, nil)
return a.handleVithResponse(err, resp.Body)
}

func (a App) renameStream(ctx context.Context, old, new absto.Item) error {
a.increaseMetric("stream", "rename")

resp, err := a.vithRequest.Method(http.MethodPatch).Path(fmt.Sprintf("%s?to=%s&type=%s", getStreamPath(old), url.QueryEscape(getStreamPath(new)), typeOfItem(old))).Send(ctx, nil)
resp, err := a.vithRequest.Method(http.MethodPatch).Path("%s?to=%s&type=%s", getStreamPath(old), url.QueryEscape(getStreamPath(new)), typeOfItem(old)).Send(ctx, nil)
return a.handleVithResponse(err, resp.Body)
}

func (a App) deleteStream(ctx context.Context, item absto.Item) error {
a.increaseMetric("stream", "delete")

resp, err := a.vithRequest.Method(http.MethodDelete).Path(fmt.Sprintf("%s?type=%s", getStreamPath(item), typeOfItem(item))).Send(ctx, nil)
resp, err := a.vithRequest.Method(http.MethodDelete).Path("%s?type=%s", getStreamPath(item), typeOfItem(item)).Send(ctx, nil)
return a.handleVithResponse(err, resp.Body)
}

0 comments on commit 17d9145

Please sign in to comment.