Skip to content

SpringBootLambdaContainerHandler doesn't set the contextPath #84

Closed
@agibalov

Description

@agibalov

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions