-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Allow modification of the response body #47
Comments
Nevermind, I just added a GlobalFilter with an order of -2 and it works. |
I'm trying, but no result... |
Hi, I'll try to make a Gist to show you how I've done (I'll have to clean up corporate code first), but in short:
Hope it makes sense. I have 2 filters that work that way (the first one removes some fields from the JSON response, the second one ciphers the body of the response in AES). |
Thanks a lot! And how do you cast the body from a Publisher<? extends DataBuffer> to a Flux? I got it "works" somehow, but always with exception "only one subscriber allowed". And that way, as I understand, is wrong. |
response.bufferFactory().allocateBuffer().asInputStream() reproduces nothing... |
I made a small example here : https://gist.github.com/WeirdBob/b25569d461f0f54444d2c0eab51f3c48 |
Thank you very much!!! |
We can simplify response body modification by using a plain
So, it can be achieved with a plain GatewayFilter, by forcing the |
How to append or modify the request body ? the length of the body may become longer, but the service behind the gateway received the request body have been truncated, some data lost. |
I solved this problem by modifying the length of the head:
private static <K, V> void copyMultiValueMap(MultiValueMap<K,V> source, MultiValueMap<K,V> target) { |
Hi,
I need to modify the body of both the request and the response (encryption/decryption).
As I see it, I can create a filter that sets a ServerHttpRequestDecorator in the exchange and override the getBody method, but I didn't find a way to do the same with the response. The WriteResponseFilter is the first filter and consequently the exchange used is the original exchange.
Would it be possible to add a ResponseBodyHandler interface to allow modifying the response body? Or did I overlook something?
Thanks in advance.
The text was updated successfully, but these errors were encountered: