V2: reverse_proxy calling next *response* handler?

Is there any valid way to allow a reverse proxy handler (currently manually invoked from a custom handler, though this should not matter since in the end we just return rp.ServeHTTP(..)) to execute middleware on the response, or does ‘terminating’ in the documentation mean it terminates both ways: both request-wise and response-wise?

If so, what would be the suggested way to alter the response from reverseproxy.Handler.ServeHTTP(), preferably without duplicating code by replicating the HTTP proxying code and doing a manual HTTP request to the backend for the URLs that we’d like to filter?

The configuration used is along the lines of the following:

						caddyhttp.Route{
							MatcherSetsRaw: caddyhttp.RawMatcherSets{
								map[string]json.RawMessage{
									"host": wrapJSON([]string{fmt.Sprintf("*.%v", domainName)}),
								},
							},
							HandlersRaw: []json.RawMessage{
								wrapJSONHandler("templates", map[string]interface{}{
									"include_root": "",
									"mime_types":   []string{"text/html", "text/plain", "text/plain; charset=utf-8"},
								}),
								wrapJSONHandler("cfx_nucleus", map[string]interface{}{}),

(wrapJSONHandler is just a helper which adds a handler key and merges in the interface itself)

EDIT: ah, mea culpa: this seems to work fine for a page with a response Content-Type of text/html; charset=utf-8, but a JSON response which has a Content-Type of text/plain; charset=utf-8 does not get the value filtered, interestingly - perhaps this is due to JSON’s usage of {}?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.