Comments (9)
I did some more investigation and determined with more certainty that indeed, the current implementation does not support Filter registration (or Servlet registration, for that matter). I also determined that HandlerInterceptor
s will not serve my particular need, so I am just going to work around this in the handleRequest
method of my own project for the time being, essentially bypassing Spring for part of my code.
I probably will not have time to patch this library to add Filter support myself any time soon, so unfortunately I can't offer a Pull Request at the moment. I'll leave the ticket open for now in case anyone else is interested in this as a feature, but I'm also okay with it if this is a "Won't Fix." Thanks!
from aws-serverless-java-container.
Correct, at the moment it does not. I'd be interested to take a look at your filter code and see if/how we can add support for it. Anything you can share on GitHub or here?
from aws-serverless-java-container.
Is this also the reason why '@Valid' isn't working?
from aws-serverless-java-container.
I'm no spring expert but doing some research I can see that the @Valid
annotation does run as a filter. We are currently designing filters support based on this issue and we'll have something in a branch over the next few weeks.
from aws-serverless-java-container.
Thanks for the answer @sapessi ..
I created a separated issue for this...
from aws-serverless-java-container.
I'll keep that issue open until I can confirm for certain that this is the cause of the issue. If it is, then I'll close the separate issue and group everything in here. Otherwise we'll address it there.
from aws-serverless-java-container.
Hey @blakeney, could you share some sample code on how you initialize (and add) filters in your spring application?
from aws-serverless-java-container.
I've pushed a first version of the filter support to the servlet-improvements branch. This is the commit d7bec0a. You can register filters with the setStartupHandler lambda:
try {
handler = SpringLambdaContainerHandler.getAwsProxyHandler(EchoSpringAppConfig.class);
handler.setStartupHandler(c -> {
FilterRegistration.Dynamic registration = c.addFilter("CustomHeaderFilter", CustomHeaderFilter.class);
// update the registration to map to a path
registration.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/*");
// servlet name mappings are disabled and will throw an exception
});
} catch (ContainerInitializationException e) {
e.printStackTrace();
}
Next I will work on supporting the filter annotations.
from aws-serverless-java-container.
Version 0.4 is out and adds support for servlet filter:
handler.setStartupHandler(c -> {
FilterRegistration.Dynamic registration = c.addFilter("CustomHeaderFilter", CustomHeaderFilter.class);
// update the registration to map to a path
registration.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/*");
// servlet name mappings are disabled and will throw an exception
});
Closing this issue.
from aws-serverless-java-container.
Related Issues (20)
- How can I get 'apigateway authorizer' context content in SpringBoot2? HOT 1
- Incorrect ServerName with ALB HOT 1
- Stable v2 release date HOT 8
- Spring throwExceptionIfNoHandlerFound is true by default as of Spring 6.1.x
- HTTP API is supported? HOT 2
- Spring for GraphQL support/ sample HOT 2
- "java.lang.NoClassDefFoundError" on Pet Store sample project HOT 3
- SpringDelegatingLambdaContainerHandler seems does not work with query parameters HOT 8
- SpringDelegatingLambdaContainerHandler should reuse AsyncInitializationWrapper HOT 5
- Not able to apply spring security on pet-store-native sample HOT 6
- No public method named handleRequest with appropriate method signature on SpringBootLambdaContainerHandler HOT 12
- `IAM` authorizer is discarded HOT 2
- Not getting reponse back directly from filter HOT 1
- Reinitialization of Spring context when using SnapStart HOT 3
- Spring Cloud Gateway throwing "hostname can't be null" based on my request only having headers and not multi-value headers HOT 4
- ServletContext: Servlet.getServletConfig() is null HOT 1
- Cannot invoke "org.springframework.web.servlet.DispatcherServlet.getServletContext()" because "servlet" is null HOT 4
- org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: No content to map due to end-of-input HOT 1
- org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: No content to map due to end-of-input HOT 8
- Cannot deserialize value of type `java.lang.String` from Object value HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aws-serverless-java-container.