spring-hateoas

How to configure Spring HATEOAS behind proxy?

孤街浪徒 提交于 2019-11-26 21:19:08
问题 I have Spring Data Rest with Hateoas as my backed. It is behind a proxy. Backend url: backend.com Proxy url: proxy.com When I query proxy url, e.g. http://proxy.com/items/1 , I get a response with href links with domain backend.com . I need the domain to be proxy.com . 回答1: As of Spring-Boot 2.1 / Spring 5.1, Spring shifts the responsibility of handling X-Forwarded-* from Spring HATEOAS to Spring MVC. https://jira.spring.io/browse/SPR-16668 You now require the registration of a filter bean.

How to correctly use PagedResourcesAssembler from Spring Data?

自闭症网瘾萝莉.ら 提交于 2019-11-26 11:52:56
问题 I\'m using Spring 4.0.0.RELEASE, Spring Data Commons 1.7.0.M1, Spring Hateoas 0.8.0.RELEASE My resource is a simple POJO: public class UserResource extends ResourceSupport { ... } My resource assembler converts User objects to UserResource objects: @Component public class UserResourceAssembler extends ResourceAssemblerSupport<User, UserResource> { public UserResourceAssembler() { super(UserController.class, UserResource.class); } @Override public UserResource toResource(User entity) { // map

Can I make a custom controller mirror the formatting of Spring-Data-Rest / Spring-Hateoas generated classes?

北城以北 提交于 2019-11-26 10:23:48
问题 I\'m trying to do something I think should be really simple. I have a Question object, setup with spring-boot, spring-data-rest and spring-hateoas. All the basics work fine. I would like to add a custom controller that returns a List<Question> in exactly the same format that a GET to my Repository \'s /questions url does, so that the responses between the two are compatible. Here is my controller: @Controller public class QuestionListController { @Autowired private QuestionRepository

Enable HAL serialization in Spring Boot for custom controller method

对着背影说爱祢 提交于 2019-11-26 09:40:01
问题 I\'m trying to build a RESTful API with Spring Boot using spring-boot-starter-data-rest. There are some entities: accounts, transactions, categories and users - just the usual stuff. When I retrieve the objects at http://localhost:8080/transactions via the API that has been generated by default, all is going well an I get a list with all transactions as JSON objects like that one: { \"amount\": -4.81, \"date\": \"2014-06-17T21:18:00.000+0000\", \"description\": \"Pizza\", \"_links\": { \"self