-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add @ContentDisposition annotation for setting Content-Disposition he… #11488
base: 4.8.x
Are you sure you want to change the base?
Conversation
@@ -26,6 +26,8 @@ dependencies { | |||
testImplementation(libs.micronaut.test.junit5) { | |||
exclude(group= "io.micronaut") | |||
} | |||
testImplementation("io.micronaut:micronaut-http-client") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please move the test to the tck
import reactor.core.publisher.Flux; | ||
|
||
/** | ||
* A filter that adds the `Content-Disposition` header to HTTP responses for specific endpoints. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add @since
* @return A publisher that emits the modified or unmodified HTTP response. | ||
*/ | ||
@Override | ||
public Publisher<MutableHttpResponse<?>> doFilter(HttpRequest<?> request, ServerFilterChain chain) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add nullability annotations
…tion.java Co-authored-by: Jonas Konrad <[email protected]>
*/ | ||
@Singleton | ||
@Filter("/**") | ||
public class ContentDispositionFilter implements HttpServerFilter { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use @ServerFilter
API
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact I'm not sure we can have a general filter like this. It will affect performance of all controllers, even those without the annotation. Potentially this change needs to go into ResponseLifecycle instead (after #11342 )
I think you can simply implement |
*/ | ||
@Override | ||
public Publisher<MutableHttpResponse<?>> doFilter(HttpRequest<?> request, ServerFilterChain chain) { | ||
if (request.getPath().startsWith("/report/result")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this class is in src/main/java
but seems to be hard coded to some test classes (ReportController
) this doesn't seem to belong here at all. What is this PR trying to achieve?
* Provides an endpoint to generate and download a CSV report. | ||
*/ | ||
@Controller("/report") | ||
public class ReportController { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should not be in src/main/java
issue #9480