spring-hateoas

XML Configuration Equivalent of @EnableHypermediaSupport

帅比萌擦擦* 提交于 2019-12-11 07:19:13
问题 I was reading through an article on REST API development with Spring-HATEOAS, as well as browsing the project page and docs, but have so far only seen example code using Java configuration. Is there an XML equivalent to @EnableHypermediaSupport and the configuration seen in the article's example? @Configuration @ComponentScan @EnableWebMvc @EnableHypermediaSupport class WebMvcConfiguration extends WebMvcConfigurationSupport { @Override public void configureContentNegotiation

How do I include the spring-boot-hateoas-starter which contains spring-hateoas version 1.0.0.M1 into my project

点点圈 提交于 2019-12-11 06:05:58
问题 Currently I am trying to migrate an API built in .NET to Java using Spring and it's related components. The only thing preventing me from completing this project is the lack of Affordances in the current release version of Spring HATEOAS (0.25.1), I am trying to replicate the data contracts as closely as I can in order to prevent breaking clients currently consuming the API. Spring HATEOAS is included via the spring-boot-starter-hateoas Maven dependency. I have tried the current build

Exposing link on collection entity using spring hateoas

元气小坏坏 提交于 2019-12-11 04:03:42
问题 I have pretty the same question as it has been asked here (Exposing link on collection entity in spring data REST). But nothing from that topic helps me to add custom link to collection call. @Component public class EventListResourceProcessor implements ResourceProcessor<Resources<Event>> { @Autowired private RepositoryEntityLinks entityLinks; @Override public Resources<Event> process(Resources<Event> events) { events.add(entityLinks.linkToCollectionResource(Event.class).withRel("events"));

Spring Boot (HATEOAS) ControllerLinkBuilder.linkTo(…) query parameter missing/not created

我们两清 提交于 2019-12-11 00:23:35
问题 I'm working on a REST API with Spring Boot (1.4) and also using the PagedResourcesAssembler to create JSON responses with pagination, which works like a charm. The guys from Spring did a great job! However I'm having issues providing the URL query parameters (if provided). I understand that the PagedResourcesAssembler can't figure out URL query parameter on its own, so I wanted to provide a Link for it, using the ControllerLinkBuilder.linkTo(controller, parameters) method: @RequestMapping

How to create Spring Data Rest entities response format manually [duplicate]

删除回忆录丶 提交于 2019-12-10 22:12:23
问题 This question already has answers here : Calling spring data rest repository method doesn't return links (2 answers) Closed 3 years ago . I'm using Spring Data Rest to create a RESTful api. I want to handle an exception returning an entity representation like the ones generated by the Spring Data Rest repositories (with HATEOAS links). The method from where I need to return the entity representation is the following: @ExceptionHandler(value = {ExistentUGVException.class}) @ResponseBody

Spring Data REST with Custom Resource URI Fails on PUT/PATCH - Spring Boot 2.0

淺唱寂寞╮ 提交于 2019-12-10 19:49:58
问题 I have a resource that is accessed via a custom resource URI. I have requirement that primary keys cannot be directly shown in a resource URI. So I modified my REST config to provided a modified EntityLookup. Appropriate snippets are as follows... Modified Configuration: @Component public class SpringDataMyDataRestCustomization extends RepositoryRestConfigurerAdapter { @Override public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) { /** * Setup hashed ID URIs *

Error on generating self link on pageable resource

非 Y 不嫁゛ 提交于 2019-12-10 16:39:21
问题 Make a simple RestController @RestController public class Controloler @Value class MyData { int value; } @GetMapping(value = "/datas", produces = MediaTypes.HAL_JSON_VALUE) public PagedResources<Resource<MyData>> getMyData(PagedResourcesAssembler<MyData> assembler, @RequestParam(required = false) String param, @PageableDefault Pageable pageRequest) { MyData data = new MyData(1); Page<MyData> page = new PageImpl<>(Collections.singletonList(data), pageRequest, 100); Link selfLink = linkTo

Zuul behind an AWS ELB over HTTPS/SSL

醉酒当歌 提交于 2019-12-10 15:17:13
问题 I have an AWS Elastic Load Balancer with the certificates for my domain and which terminates the SSL traffic. The ELB has a listener on the https port and forwards it as http to Zuul . When I use Spring Boot HATEOAS , Zuul will replace the links with the correct address but with http instead of https : "_links": { "self": { "href": "http://my.domain.com:80/rest/foo/bar" } } but what I want is: "_links": { "self": { "href": "https://my.domain.com/rest/foo/bar" } } The request that generates

How to build a templated link?

廉价感情. 提交于 2019-12-10 14:17:35
问题 I have a method with a request parameter and I'm trying to link to this method from another resource. I want the link to be something like this: "rel":{ "href":".../resources{?param}", "templated":true } I tried the following without success: //First attempt resources.add(linkTo(methodOn(Controller.class).method(null)).withRel("rel") //Second attempt resources.add(linkTo(methodOn(Controller.class).method("{parameter}")).withRel("rel") //Third attempt resources.add(entityLinks

Spring HATEOAS (w Spring Boot) JAXB marshal error when returning a Resources<T> or PagedResources<T> result

喜欢而已 提交于 2019-12-10 13:44:33
问题 I've got something like this in my controller: @RequestMapping @ResponseBody public HttpEntity<PagedResources<PromotionResource>> promotions( @PageableDefault(size = RestAPIConfig.DEFAULT_PAGE_SIZE, page = 0) Pageable pageable, PagedResourcesAssembler<Promotion> assembler ){ PagedResources<PromotionResource> r = assembler.toResource(this.promoService.find(pageable), this.promoAssembler); return new ResponseEntity<PagedResources<PromotionResource>>(r, HttpStatus.OK); } If i navigate to the URL