How to customize Spring Data REST to use a multi-segment path for a repository resource?

二次信任 提交于 2019-11-28 01:51:24

tl;dr

Not supported.

Details

Generally speaking: don't focus on designing URLs. The structure of a URI must not matter to a REST client by definition:

At no time whatsoever do the server or client software need to know or understand the meaning of a URI -- they merely act as a conduit through which the creator of a resource (a human naming authority) can associate representations with the semantics identified by the URI.

(from Roy Fielding - Architectural Styles and the Design of Network-based Software Architectures - Section 6.2.4)

If you follow that criteria, you take care of choosing relation names, design the representations for the resources you expose etc.

That said, what you're looking for is currently not supported. If you think it's worthwhile adding this feature (I think it's not, due to the argument given above), feel free to open a ticket in our bug tracker.

It's probably quite tricky to implement due to the way Spring MVC mapping works and especially the combination of mapping of singular path segments and non-singular ones could cause some ambiguities. All of that makes it rather unlikely this request will get followed up on.

Andreas Aumayr

I think this (or: a similar) question was already answered here on stackoverflow.

Set the base uri using a custom RepositoryRestMvcConfiguration class.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!