Having different Paths in the same Rest API











up vote
1
down vote

favorite












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}










share|improve this question
























  • 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 8 at 8:30










  • Thanks, my intention is not to follow best practices, but if it is possible.
    – user217648
    Nov 8 at 8:47















up vote
1
down vote

favorite












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}










share|improve this question
























  • 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 8 at 8:30










  • Thanks, my intention is not to follow best practices, but if it is possible.
    – user217648
    Nov 8 at 8:47













up vote
1
down vote

favorite









up vote
1
down vote

favorite











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}










share|improve this question















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}







rest spring-boot path endpoint






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 8 at 8:49

























asked Nov 8 at 8:28









user217648

1,01032046




1,01032046












  • 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 8 at 8:30










  • Thanks, my intention is not to follow best practices, but if it is possible.
    – user217648
    Nov 8 at 8:47


















  • 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 8 at 8:30










  • Thanks, my intention is not to follow best practices, but if it is possible.
    – user217648
    Nov 8 at 8:47
















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 8 at 8:30




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 8 at 8:30












Thanks, my intention is not to follow best practices, but if it is possible.
– user217648
Nov 8 at 8:47




Thanks, my intention is not to follow best practices, but if it is possible.
– user217648
Nov 8 at 8:47












1 Answer
1






active

oldest

votes

















up vote
1
down vote













It is possible like below.



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


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






share|improve this answer





















  • 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 8 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 8 at 12:27













Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53203900%2fhaving-different-paths-in-the-same-rest-api%23new-answer', 'question_page');
}
);

Post as a guest
































1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote













It is possible like below.



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


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






share|improve this answer





















  • 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 8 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 8 at 12:27

















up vote
1
down vote













It is possible like below.



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


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






share|improve this answer





















  • 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 8 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 8 at 12:27















up vote
1
down vote










up vote
1
down vote









It is possible like below.



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


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






share|improve this answer












It is possible like below.



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


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







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 8 at 9:11









Alien

3,53821022




3,53821022












  • 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 8 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 8 at 12:27




















  • 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 8 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 8 at 12:27


















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 8 at 11: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 8 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 8 at 12:27






that you can not control like this if you have any base mapping url for controller also for different server.
– Alien
Nov 8 at 12:27




















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53203900%2fhaving-different-paths-in-the-same-rest-api%23new-answer', 'question_page');
}
);

Post as a guest




















































































Popular posts from this blog

Schultheiß

Verwaltungsgliederung Dänemarks

Liste der Kulturdenkmale in Wilsdruff