spring-hateoas

How to create link pointing to Spring controller action that returns void

China☆狼群 提交于 2019-12-10 13:21:10
问题 I am using spring mvc, hateoas. I have a controller action that looks like @RequestMapping(value = "/images/{userId}/{publicUrl}/{fileName:.+}", method = RequestMethod.GET) public void image(@PathVariable Integer userId, @PathVariable String publicUrl, @PathVariable String fileName, HttpServletRequest request, HttpServletResponse response) throws Exception { try(HellodoxAws aws = haws;){ ..... ..... response.setContentType(image.getObjectMetadata().getContentType()); response.setHeader("ETag"

ALPS metadata for all Spring-MVC Controller

吃可爱长大的小学妹 提交于 2019-12-10 12:46:54
问题 I've a question about the ALPS support in spring hateoas/data rest. It seems that the ALPS metadata are only exposed if you have a spring data rest repository. So my question is why is there only a support for the spring data rest repository and can I enable it for all spring mvc controllers? Is there any example to expose the ALPS metadata for all controllers? Maybe I haven't understood the conept of ALPS... Greets Meleagros http://spring.io/blog/2014/07/14/spring-data-rest-now-comes-with

Consuming HAL-based REST service with spring-hateoas

人走茶凉 提交于 2019-12-10 11:55:41
问题 I'm trying to consume a HAL-based REST service with the RestTemplate class. The response body looks like this: { "_embedded": { "school:teachers": [ { "name": "Adams", "state": "CA", "_links": { "self": { "href": "http://localhost:8080/api/teachers/1" } } }, { "name": "Barnes", "state": "FL", "_links": { "self": { "href": "http://localhost:8080/api/teachers/2" } } }, { "name": "Armstrong", "state": "GA", "_links": { "self": { "href": "http://localhost:8080/api/teachers/3" } } } ] }, "_links":

Spring Data Rest Ambiguous Association Exception

我们两清 提交于 2019-12-10 03:10:54
问题 The newly added LinkCollectingAssociationHandler is throwing a MappingException due to an ambiguous association in my domain class. The links array looks like this: [<http://localhost:8080/rooms/2/roomGroups>;rel="roomGroups", <http://localhost:8080/rooms/2/userGroup>;rel="userGroup", <http://localhost:8080/rooms/2/room>;rel="room", <http://localhost:8080/rooms/2/originatingConferences>;rel="originatingConferences", <http://localhost:8080/rooms/2/user>;rel="user"] And it is trying to add

Adding more information to the HATEOAS response in Spring Boot Data Rest

假如想象 提交于 2019-12-09 19:17:42
问题 I have the following REST controller. @RepositoryRestController @RequestMapping(value = "/booksCustom") public class BooksController extends ResourceSupport { @Autowired public BooksService booksService; @Autowired private PagedResourcesAssembler<Books> booksAssembler; @RequestMapping("/search") public HttpEntity<PagedResources<Resource<Books>>> search(@RequestParam(value = "q", required = false) String query, @PageableDefault(page = 0, size = 20) Pageable pageable) { pageable = new

Spring HATEOAS Resource Assembler and Resource Links with many variables

别说谁变了你拦得住时间么 提交于 2019-12-09 19:15:38
问题 I'm working on REST API with Spring HATEOAS and the Spring stack, and i have some problems with links into resources. Here is my code : the Controller : @RestController @RequestMapping("/apporteurs/{idInt}/ribs") public class RibController { @Autowired private RibResourceAssembler ribResourceAssembler; @Autowired private RibRepository ribRepository; /** * Methode GET permettant d'obtenir un Rib par son ID * * @param idRib ID du Rib * @return RibResource */ @RequestMapping(value = "/{idRib}",

Exposing link on collection entity in spring data REST

你离开我真会死。 提交于 2019-12-08 22:22:30
问题 Using spring data REST I have exposed a ProjectRepository that supports listing projects and performing CRUD operations on them. When I go to http://localhost:8080/projects/ I get the list of projects as I expect. What I am trying to do is add a custom action to the _links section of the JSON response for the Project Collection. For example, I'd like the call to http://localhost:8080/projects/ to return something like this: { "_links" : { "self" : { "href" : "http://localhost:8080/projects/{

Implementing/Overriding MongoRepository Keep HATEOAS Formatting

半城伤御伤魂 提交于 2019-12-08 06:22:21
问题 I have a simple MongoRepository I would like to modify to return the generated ObjectId on post(save()). public interface EmployeeRepository extends MongoRepository<Employee, String> { public void delete(Employee employee); public Employee save(Employee employee); public Employee findOne(String id); public List<Employee> findAll(); public Employee findByName(String principal); } I have explored ways to generate the id client side and pass it in the post BUT I really want Spring to handle this

Spring's MockMVC Responses Don't Match Browser Response

旧巷老猫 提交于 2019-12-08 04:57:14
问题 For some reason, my Spring controller is returning different responses if I access it via a browser or via my MockMVC test class. Could someone help me spot why? First the controller method: @RequestMapping(value = APPLICATIONS_ROOT, method = GET) public HttpEntity<ApplicationsListResource> listApplications(@PageableDefault(page = DEFAULT_START, size = DEFAULT_HITS_PER_PAGE) Pageable pageable) { Page<Application> applications = applicationRepository.findAll(pageable); ApplicationsListResource

Spring Boot Zuul hateoas REST response has direct service links in resource

两盒软妹~` 提交于 2019-12-08 04:54:53
问题 I have Zuul + Eureka + Spring Boot Service Endpoint + Hateoas response configuration. When I access the service through Zuul Gateway, the resource links in the response are direct links to the service endpoints, shouldn't they be the Gateway links? What am i missing here? Gateway Endpoint : http://localhost:8762/catalog/products/10001 Direct Service Endpoint : http://localhost:8100/products/10001 application.properties for Zuul spring.application.name=zuul-server eureka.client.service-url