Skip to content

Commit

Permalink
Merge pull request #19 from nittin-cz/refactor/crawler
Browse files Browse the repository at this point in the history
refactor Web Crawler example - use constructor DI instead of Service.…
  • Loading branch information
Lahvac authored Sep 22, 2023
2 parents dd2ccad + 780bc01 commit f992e8e
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ public class WebCrawlerService
private readonly HttpClient httpClient;
private readonly IPageUrlRetriever urlRetriever;
private readonly IEventLogService eventLogService;
private readonly IAppSettingsService appSettingsService;

public WebCrawlerService(HttpClient httpClient, IPageUrlRetriever urlRetriever, IEventLogService eventLogService)
public WebCrawlerService(HttpClient httpClient, IPageUrlRetriever urlRetriever, IEventLogService eventLogService, IAppSettingsService appSettingsService)
{
this.appSettingsService = appSettingsService;
this.httpClient = httpClient;
// configure the client inside constructor if needed (add custom headers etc.)
this.httpClient.DefaultRequestHeaders.Add(HeaderNames.UserAgent, "SearchCrawler");
// get crawler base url from settings or site configuration, make sure that WebCrawlerBaseUrl is correct
string baseUrl = ValidationHelper.GetString(Service.Resolve<IAppSettingsService>()["WebCrawlerBaseUrl"], DocumentURLProvider.GetDomainUrl("DancingGoatCore"));
string baseUrl = ValidationHelper.GetString(appSettingsService["WebCrawlerBaseUrl"], DocumentURLProvider.GetDomainUrl("DancingGoatCore"));
this.httpClient.BaseAddress = new Uri(baseUrl);

this.urlRetriever = urlRetriever;
Expand Down

0 comments on commit f992e8e

Please sign in to comment.