Skip to content

Commit

Permalink
Resolving the context issue and bad client
Browse files Browse the repository at this point in the history
  • Loading branch information
COMTOP1 committed Jan 2, 2025
1 parent 7d758d3 commit 8d37da3
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions services/encoder/encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,15 @@ func (e *Encoder) CreateEncode(ctx context.Context, file VideoFile, formatID int
return EncodeResult{}, fmt.Errorf("failed to marshal json: %w", err)
}

res, err := e.c.Post(e.conf.VTEndpoint+"/task/video/vod", "application/json", bytes.NewReader(reqJSON))
req, err := http.NewRequestWithContext(ctx, http.MethodPost, e.conf.VTEndpoint+"/task/video/vod", bytes.NewReader(reqJSON))
if err != nil {
return EncodeResult{}, fmt.Errorf("failed to post to vt: %w", err)
}

defer func(Body io.ReadCloser) {
err = Body.Close()
if err != nil {
fmt.Println(err)
}
}(res.Body)
res, err := http.DefaultClient.Do(req)
if err != nil {
return EncodeResult{}, fmt.Errorf("failed to post to vt: %w", err)
}
defer res.Body.Close()

switch status := res.StatusCode; {
case status == http.StatusCreated:
Expand Down

0 comments on commit 8d37da3

Please sign in to comment.