Rewrite is a middleware which can rewrite/mutate HTTP requests. The Method and URI properties are "setters" (the request URI will be overwritten with the given values). Other properties are "modifiers" (they modify existing values in a differentiable way). It is atypical to combine the use of sette
| 52 | // slashes will not be merged while cleaning the path so that |
| 53 | // the rewrite can be interpreted literally. |
| 54 | type Rewrite struct { |
| 55 | // Changes the request's HTTP verb. |
| 56 | Method string `json:"method,omitempty"` |
| 57 | |
| 58 | // Changes the request's URI, which consists of path and query string. |
| 59 | // Only components of the URI that are specified will be changed. |
| 60 | // For example, a value of "/foo.html" or "foo.html" will only change |
| 61 | // the path and will preserve any existing query string. Similarly, a |
| 62 | // value of "?a=b" will only change the query string and will not affect |
| 63 | // the path. Both can also be changed: "/foo?a=b" - this sets both the |
| 64 | // path and query string at the same time. |
| 65 | // |
| 66 | // You can also use placeholders. For example, to preserve the existing |
| 67 | // query string, you might use: "?{http.request.uri.query}&a=b". Any |
| 68 | // key-value pairs you add to the query string will not overwrite |
| 69 | // existing values (individual pairs are append-only). |
| 70 | // |
| 71 | // To clear the query string, explicitly set an empty one: "?" |
| 72 | URI string `json:"uri,omitempty"` |
| 73 | |
| 74 | // Strips the given prefix from the beginning of the URI path. |
| 75 | // The prefix should be written in normalized (unescaped) form, |
| 76 | // but if an escaping (`%xx`) is used, the path will be required |
| 77 | // to have that same escape at that position in order to match. |
| 78 | StripPathPrefix string `json:"strip_path_prefix,omitempty"` |
| 79 | |
| 80 | // Strips the given suffix from the end of the URI path. |
| 81 | // The suffix should be written in normalized (unescaped) form, |
| 82 | // but if an escaping (`%xx`) is used, the path will be required |
| 83 | // to have that same escape at that position in order to match. |
| 84 | StripPathSuffix string `json:"strip_path_suffix,omitempty"` |
| 85 | |
| 86 | // Performs substring replacements on the URI. |
| 87 | URISubstring []substrReplacer `json:"uri_substring,omitempty"` |
| 88 | |
| 89 | // Performs regular expression replacements on the URI path. |
| 90 | PathRegexp []*regexReplacer `json:"path_regexp,omitempty"` |
| 91 | |
| 92 | // Mutates the query string of the URI. |
| 93 | Query *queryOps `json:"query,omitempty"` |
| 94 | |
| 95 | logger *zap.Logger |
| 96 | } |
| 97 | |
| 98 | // CaddyModule returns the Caddy module information. |
| 99 | func (Rewrite) CaddyModule() caddy.ModuleInfo { |
nothing calls this directly
no outgoing calls
no test coverage detected