Skip to content
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

HttpWebHandlerAdapter needs possibility to manipulate requests before their handle #32942

Closed
antechrestos opened this issue Jun 3, 2024 · 2 comments
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement

Comments

@antechrestos
Copy link

Currently HttpWebHandlerAdapter handles requests as follows

  1. handle x forwarded header which manipulates the request
  2. instanciates exchange
  3. instanciates observation context
  4. run handle

My need was to populate traceparent from a X-Correlation-Id header. I was stuck as I would have need to insert something before point 3 and nothing was possible.

I ended by implementing a BeanPostProcessor which wraps the HttpHandler instance and manipulates request before anything, hence before point 1.

I would suggest something like

  • create an interface the describe the manipulation of entering http request
  • make the ForwardedHeaderTransformer implement it
  • get all implementation when the HttpHandler is instanciated (instead of getting a nullable instance of ForwardedHeaderTransformer

Is this understandable?
I also think that it may lead ti misunderstanding with WebFilter.

Maybe the issue is with points 1 and 2 doing things out of the common lifecycle.

@bclozel bclozel added the in: web Issues in web modules (web, webmvc, webflux, websocket) label Jun 3, 2024
@snicoll snicoll added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jun 3, 2024
@bclozel
Copy link
Member

bclozel commented Jun 4, 2024

This feature is already available. When building the HttpHandler with WebHttpHandlerBuilder, you can decorate it with the httpHandlerDecorator on that builder. In Spring Boot, you can contribute a WebHttpHandlerBuilderCustomizer bean to do that.

@bclozel bclozel closed this as not planned Won't fix, can't repro, duplicate, stale Jun 4, 2024
@bclozel bclozel added status: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jun 4, 2024
@antechrestos
Copy link
Author

@bclozel ah ok thanks; my bad, I was looking 3.2.5 code version. I cannot migrate due to an issue I found in spring data mongo ..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants