Question: I have a REST endpoint implemented with Spring MVC @RestController. Sometime, depends on input parameters in my controller I need to send http redirect on client. 

Is it possible with Spring MVC @RestController and if so, could you please show an example ?

Answer: 
To avoid any direct dependency on `HttpServletRequest` or `HttpServletResponse` I suggest a "pure Spring" implementation returning a [ResponseEntity](https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/http/ResponseEntity.html) like this:

```
HttpHeaders headers = new HttpHeaders();
headers.setLocation(URI.create(newUrl));
return new ResponseEntity<>(headers, HttpStatus.MOVED_PERMANENTLY);

```

If your method always returns a redirect, use `ResponseEntity<Void>`, otherwise whatever is returned normally as generic type.
if you @RestController returns an **String** you can use something like this

```
return "redirect:/other/controller/";

```

and this kind of redirect is only for **GET** request, if you want to use other type of request use HttpServletResponse