Using spring boot for simple REST application.
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
I have a simple controller that handles requests.
@RestController
@RequestMapping("/api")
public class MainController {
@RequestMapping("/test")
public BasicDTO getBasic(HttpServletRequest request){
System.out.println(request.getRemoteAddr());
return new BasicDTO();
}
}
The HttpServletRequest
context does not get injected. How can I inject the request context into the method so that I can access some basic socket details? Thanks.