-
-
Notifications
You must be signed in to change notification settings - Fork 4.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
Feature Request: Sanitize/reformat/remap content retrieved via reverse_proxy #3848
Comments
You can already do this with the This type of rewriting of the response is more a job for a Caddy plugin to handle. https://caddyserver.com/docs/extending-caddy |
I can't remember if those handlers have access to the response body... |
@mholt the description says:
So, I think so? Edit: Hmm, nope. It does
So @mholt 🤷♂️ what do you want to do with this? |
Help me out here since I'm new to caddy and a little naive, do I need to write a rust-based module to extend caddy in order to implement the handler or is there something in the config that lets me write some code that allows me to translate the XML to JSON already? |
Caddy's a Go project, not Rust. There's nothing currently in Caddy to make this possible, and frankly it's out of scope of the core of the project, and should be implemented as a plugin if you need it. But as @mholt pointed out, I don't think it's possible to grab the |
Oops, sorry, handling a lot of languages these days and confused Rust with Go, sorry. OK, so if I go lookup the |
Sure, it's in here: https://github.com/caddyserver/caddy/tree/master/modules/caddyhttp/encode This document explains everything you should need to know to write plugins: https://caddyserver.com/docs/extending-caddy A plugin would be a separate repo, and it's easiest to compile it in with the |
When I implemented that, I only thought about it for a few minutes and was like, "Well I don't know what to do with the body... I guess we'll just close it," and came to the same conclusion you did, about a middleware handler wrapping the response so that it could intercept it itself. I would like a better way to handle responses from proxy upstreams, but didn't figure anything out in the few minutes I spent on it. |
It would be helpful to be able to sanitize, reformat, and remap content in response bodies retrieved via reverse_proxy before handing back to the requestor. For example, it could allow you to convert an XML response body to JSON, or to remap attributes to a more common format before it is returned.
The text was updated successfully, but these errors were encountered: