Closed
Description
Spring provides a nice mechanism to build URLs by referencing controller classes and their handler methods:
URI personUri = fromMethodCall(on(PersonsController.class)
.getPerson(123))
.build().toUri();
Internally, this mechanism relies on the current ServletRequest
and namely its getContextPath()
method.
I see that while my AwsProxyRequest
has these details:
getPath(): /hello
getRequestContext().getPath(): /Dummy/hello
getResource(): /{proxy+}
SpringBootLambdaContainerHandler
creates the ServletRequest
object like this:
getPathInfo(): /hello
getPathTranslated(): null
getContextPath():
getServletPath(): /hello
getServletContext().getContextPath(): /
As a result, when I build the URL, the API Gateway's "stage" part is lost ("Dummy" is a stage) and instead of http://apigw/Dummy/hello
, I get http://apigw/hello
.
We're using aws-serverless-java-container-spring:0.8
with spring-boot-starter-web:1.5.3.RELEASE
.