I'm currently developing a Spring Boot application that exposes endpoints using @RestController and @RequestMapping annotations.
I recently discovered the concept of the projections as defined in Spring Data Rest (@Projection-annotated interfaces and @RepositoryRestResource-annotated JPA repositories) and I'd like to apply this concept to my existing services.
As I understand this post Spring Boot Projection with RestController, (please correct me if I'm wrong), @RestController and @RepositoryRestResource classes both define endpoints. So these annotations seem quite incompatible.
Is there a Spring component which can simply apply the projections concept to the @RestController endpoints ?
Is there a way to manually reroute requests from a endpoint to another ? (for example, using @RestController endpoints as some sort of proxy which performs controls or other operations before rerouting the request to the @RepositoryRestResource endpoints)
EDIT: I add a glimpse of the final code I'd like to have in the end.
@RestController
public class MyController {
    @RequestMapping(value = "/elements/{id}", method = RequestMethod.GET)
    public ResponseEntity<Element> getElements( 
            @PathVariable("id") Integer elementId,
            @RequestParam("projection") String projection,
            @RequestHeader(value = "someHeader") String header{
        // [manual controls on the header then call to a service which returns the result]
    }
}
@Entity
public class Element {
    private Integer id;
    private String shortField;
    private String longField;
    private List<SubElement> subElements;
    // [Getters & setters]
}
@Projection(name = "light", types = {Element.class})
interface ElementLight {
    public Integer getId();
    public String getShortField();
}
If I call /elements/4, I'd get the complete Element having id = 4.
If I call /elements/4?projection=light, I'd get only the id and the short field of the Element having id = 4.
 
     
    