Add boot42-preview module: Spring Boot 4.2.0-M2 vs 4.1.1 forwarded headers, AMQP starters, buildpack cache, RestTemplate removal warnings
Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Gth99spB1CzQmBFofXmU4Z
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
package com.ankurm.boot42;
|
||||
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/** Minimal application. Every experiment in this module lives in src/test. */
|
||||
@SpringBootApplication
|
||||
@org.springframework.boot.context.properties.EnableConfigurationProperties(OrderProperties.class)
|
||||
public class Boot42PreviewApplication {
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.ankurm.boot42;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/** A Set and a Map bound from a file where the keys are deliberately not alphabetical. */
|
||||
@ConfigurationProperties("app")
|
||||
public record OrderProperties(Set<String> regions, Map<String, Integer> limits) {
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.ankurm.boot42;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.client.RestClient;
|
||||
|
||||
/** What the deprecated RestTemplateBuilder code turns into: an injected RestClient.Builder. */
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
class RestClientReplacement {
|
||||
|
||||
@Bean
|
||||
RestClient inventoryClient(RestClient.Builder builder) {
|
||||
return builder.baseUrl("http://inventory.internal").build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.ankurm.boot42;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/** Echoes what the servlet container believes about the request, after any forwarded-header handling. */
|
||||
@RestController
|
||||
class WhoAmIController {
|
||||
|
||||
@GetMapping("/whoami")
|
||||
Map<String, Object> whoAmI(HttpServletRequest request) {
|
||||
Map<String, Object> m = new LinkedHashMap<>();
|
||||
m.put("scheme", request.getScheme());
|
||||
m.put("secure", request.isSecure());
|
||||
m.put("serverName", request.getServerName());
|
||||
m.put("serverPort", request.getServerPort());
|
||||
m.put("remoteAddr", request.getRemoteAddr());
|
||||
return m;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user