summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/matchers.go
diff options
context:
space:
mode:
authorFrancis Lavoie <lavofr@gmail.com>2021-05-02 14:39:06 -0400
committerGitHub <noreply@github.com>2021-05-02 12:39:06 -0600
commite4a22de9d1c4d7aa83126ee13e40b61e7b0e9df0 (patch)
tree82e3134b3c83d258fb08299e917cfa9b9d980ff7 /modules/caddyhttp/matchers.go
parente6f6d3a4765565b09f95a29a2e75be34e1d70359 (diff)
reverseproxy: Add `handle_response` blocks to `reverse_proxy` (#3710) (#4021)
* reverseproxy: Add `handle_response` blocks to `reverse_proxy` (#3710) * reverseproxy: complete handle_response test * reverseproxy: Change handle_response matchers to use named matchers reverseproxy: Add support for changing status code * fastcgi: Remove obsolete TODO We already have d.Err("transport already specified") in the reverse_proxy parsing code which covers this case * reverseproxy: Fix support for "4xx" type status codes * Apply suggestions from code review Co-authored-by: Matt Holt <mholt@users.noreply.github.com> * caddyhttp: Reorganize response matchers * reverseproxy: Reintroduce caddyfile.Unmarshaler * reverseproxy: Add comment mentioning Finalize should be called Co-authored-by: Maxime Soulé <btik-git@scoubidou.com> Co-authored-by: Matt Holt <mholt@users.noreply.github.com>
Diffstat (limited to 'modules/caddyhttp/matchers.go')
-rw-r--r--modules/caddyhttp/matchers.go34
1 files changed, 0 insertions, 34 deletions
diff --git a/modules/caddyhttp/matchers.go b/modules/caddyhttp/matchers.go
index eaf43e9..9b127db 100644
--- a/modules/caddyhttp/matchers.go
+++ b/modules/caddyhttp/matchers.go
@@ -971,40 +971,6 @@ func (mre *MatchRegexp) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
return nil
}
-// ResponseMatcher is a type which can determine if an
-// HTTP response matches some criteria.
-type ResponseMatcher struct {
- // If set, one of these status codes would be required.
- // A one-digit status can be used to represent all codes
- // in that class (e.g. 3 for all 3xx codes).
- StatusCode []int `json:"status_code,omitempty"`
-
- // If set, each header specified must be one of the
- // specified values, with the same logic used by the
- // request header matcher.
- Headers http.Header `json:"headers,omitempty"`
-}
-
-// Match returns true if the given statusCode and hdr match rm.
-func (rm ResponseMatcher) Match(statusCode int, hdr http.Header) bool {
- if !rm.matchStatusCode(statusCode) {
- return false
- }
- return matchHeaders(hdr, rm.Headers, "", nil)
-}
-
-func (rm ResponseMatcher) matchStatusCode(statusCode int) bool {
- if rm.StatusCode == nil {
- return true
- }
- for _, code := range rm.StatusCode {
- if StatusCodeMatches(statusCode, code) {
- return true
- }
- }
- return false
-}
-
var wordRE = regexp.MustCompile(`\w+`)
const regexpPlaceholderPrefix = "http.regexp"