4

I have a spring boot application with the following context path:

server.servlet.context-path:/api

I need to write a rest controller that's mapped to http://localhost:8080/logout instead of http://localhost:8080/api/logout

Is there a way to achieve this? changing the "server.servelt.context-path" value is not an option.

this is what I tried and didn't work:

@GetMapping(value="../signout"){
public void logout(){
}
8
  • And what exactly is your question? Commented Oct 18, 2019 at 19:54
  • 2
    No, it's not possible. You both want a different context path, and refuse to change the one you use. Commented Oct 18, 2019 at 19:58
  • When you set the context path... you are saying your whole application falls under that path Commented Oct 18, 2019 at 19:59
  • What is the issue with http://localhost:8080/api/logout Commented Oct 18, 2019 at 20:00
  • 1
    The reason I wanted to do this is /api is protected by our siteminder. But the logout url needs to be an unprotected path as per the siteminder SME. Hence the need to not have context path in the logout url Commented Oct 18, 2019 at 20:02

2 Answers 2

1

Nero, you say you can't change the "server.servlet.context-path" value. I bet you say this because you don't want to break the API, but I think you can manage to change this without breaking the API. Set the context-path to blank, which is permitted. Then in your application change the "api" mapping, which I assume is currently "/", to "api".

  1. Change server.servlet.context-path:/api to server.servlet.context-path:/ or maybe server.servlet.context-path: (no slash). (Supposedly this is the default so you might just remove this entry altogether.)

  2. Somewhere in your application change @RequestMapping("/") to @RequestMapping("/api").

Now you can also have @GetMapping(value="/signout") and you will have resources at http://localhost:8080/logout and http://localhost:8080/api.

I don't know what mapping annotations you happen to be using, but hopefully this is clear enough.

Sign up to request clarification or add additional context in comments.

Comments

0

It may not be possible within that application to go outside its context root. Maybe you can create a separate Rest service app for that particular url and take it from there.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.