1

We are using Spring. Is it possible to have different paths in the same REST service. We have one service and we want to have two different endpoints like following in the same REST API. I don't want to follow the best prictices. My question is if it is possible and how? thanks.

http_//domain.com/product/{id} http_//domain.com/user/{id}

user217648
  • 3,338
  • 9
  • 37
  • 61
  • Of course. Whether it is a good idea or not or how to do it with your particular libraries are potentially more interesting questions than this, however... – Ken Y-N Nov 08 '18 at 08:30
  • Thanks, my intention is not to follow best practices, but if it is possible. – user217648 Nov 08 '18 at 08:47

1 Answers1

1

It is possible like below.

@RequestMapping({ "/product/{id}", "/user/{id}" })

Refer multiple-requestmapping-value-with-path-variables

Alien
  • 15,141
  • 6
  • 37
  • 57
  • But if you have different Services on the same server, does it needs to know which server the endpoints belong to? The service it self adds some root path before /product or /user. I need to remove it to. – user217648 Nov 08 '18 at 11:57
  • that you can not control like this if you have any base mapping url for controller also for different server. – Alien Nov 08 '18 at 12:27