Demoonstrate that changing the servlet context path via Spring Boot works.#31
Open
Demoonstrate that changing the servlet context path via Spring Boot works.#31
Conversation
When applying `server.servlet.context-path=/ctx`, the links automatically adjust.
```
2020-04-13 10:43:59.877 INFO 79416 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path '/ctx'
```
Testing with curl...
```
$ curl localhost:8080/ctx/employees | jq
{
"_embedded": {
"employees": [
{
"id": 1,
"firstName": "Frodo",
"lastName": "Baggins",
"role": "ring bearer",
"fullName": "Frodo Baggins",
"_links": {
"self": {
"href": "http://localhost:8080/ctx/employees/1"
},
"employees": {
"href": "http://localhost:8080/ctx/employees"
}
}
},
{
"id": 2,
"firstName": "Bilbo",
"lastName": "Baggins",
"role": "burglar",
"fullName": "Bilbo Baggins",
"_links": {
"self": {
"href": "http://localhost:8080/ctx/employees/2"
},
"employees": {
"href": "http://localhost:8080/ctx/employees"
}
}
}
]
},
"_links": {
"self": {
"href": "http://localhost:8080/ctx/employees"
}
}
}
```
Contributor
|
If the issue is closed due to no feedback from issuer / others, should we close / merge this one? |
|
Hi, I've notice that this does not work correctly if you are using
called from
If those ThreadLocals are not set, it drops the context path in the link that's generated. I found this issue from spring-projects/spring-hateoas#1268 which has been closed now. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When applying
server.servlet.context-path=/ctx, the links automatically adjust.Testing with curl...