♻️ Use provided context in HTTP profile repository method

This commit is contained in:
Maxim Lebedev 2024-05-15 14:32:37 +05:00
parent 6ffdc532ec
commit efe077f181
Signed by: toby3d
GPG Key ID: 1F14E25B7C119FC5
1 changed files with 7 additions and 2 deletions

View File

@ -27,8 +27,13 @@ func NewHTPPClientRepository(client *http.Client) profile.Repository {
}
//nolint:cyclop,funlen
func (repo *httpProfileRepository) Fetch(_ context.Context, me domain.Me) (*domain.Profile, error) {
resp, err := repo.client.Get(me.String())
func (repo *httpProfileRepository) Fetch(ctx context.Context, me domain.Me) (*domain.Profile, error) {
req, err := http.NewRequestWithContext(ctx, http.MethodGet, me.String(), nil)
if err != nil {
return nil, fmt.Errorf("cannot build request to provided me '%s': %w", me, err)
}
resp, err := repo.client.Do(req)
if err != nil {
return nil, fmt.Errorf("%w: cannot fetch user by me: %w", profile.ErrNotExist, err)
}