Skip to content

Commit

Permalink
FIX: added dependency injection in GithubServiceImpl with proper WebC…
Browse files Browse the repository at this point in the history
…lient.Builder
  • Loading branch information
Janek1010 committed Feb 15, 2024
1 parent 6c981b8 commit f7ab927
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.example.githubservice.model.dtos.BranchDTO;
import org.example.githubservice.model.dtos.RepositoryDTO;
import org.example.githubservice.service.api.GithubService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Primary;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
Expand All @@ -18,8 +19,8 @@ public class GithubServiceImpl implements GithubService {
private final String REPOS_OF_USER = "/users/{username}/repos";
private final WebClient webClient;

public GithubServiceImpl() {
this.webClient = WebClient.create("https://api.github.com");
public GithubServiceImpl(WebClient.Builder webClientBuilder, @Value("${github.api.base-url}") String rootUrl) {
this.webClient = webClientBuilder.baseUrl(rootUrl).build();
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@

github.api.base-url=https://api.github.com

0 comments on commit f7ab927

Please sign in to comment.