Skip to content

Commit

Permalink
Set User-Agent header when making requests against api.spring.io
Browse files Browse the repository at this point in the history
Closes gh-1635
  • Loading branch information
mhalbritter committed Nov 5, 2024
1 parent e5f4987 commit 1fb8caa
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.http.HttpHeaders;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.util.StringUtils;
import org.springframework.web.client.RestTemplate;

/**
* Initializr website application.
Expand All @@ -64,7 +66,9 @@ public HomeController homeController() {
@Bean
public StartInitializrMetadataUpdateStrategy initializrMetadataUpdateStrategy(
RestTemplateBuilder restTemplateBuilder, ObjectMapper objectMapper) {
return new StartInitializrMetadataUpdateStrategy(restTemplateBuilder.build(), objectMapper);
RestTemplate restTemplate = restTemplateBuilder.defaultHeader(HttpHeaders.USER_AGENT, "start.spring.io")
.build();
return new StartInitializrMetadataUpdateStrategy(restTemplate, objectMapper);
}

@Bean
Expand Down

0 comments on commit 1fb8caa

Please sign in to comment.