| 320 | } |
| 321 | |
| 322 | func (c *UserServiceClient) GetUser(ctx context.Context, userID int64) (*User, error) { |
| 323 | resp, err := http.Get(fmt.Sprintf("%s/user/get?id=%d", c.baseURL, userID)) |
| 324 | if err != nil { |
| 325 | return nil, err |
| 326 | } |
| 327 | defer resp.Body.Close() |
| 328 | |
| 329 | if resp.StatusCode == http.StatusNotFound { |
| 330 | return nil, status.Errorf(codes.NotFound, "user not found") |
| 331 | } |
| 332 | |
| 333 | var user User |
| 334 | if err := json.NewDecoder(resp.Body).Decode(&user); err != nil { |
| 335 | return nil, err |
| 336 | } |
| 337 | |
| 338 | return &user, nil |
| 339 | } |
| 340 | |
| 341 | func (c *UserServiceClient) ValidateUser(ctx context.Context, userID int64) (bool, error) { |
| 342 | resp, err := http.Get(fmt.Sprintf("%s/user/validate?id=%d", c.baseURL, userID)) |