Merge pull request #1216 from timoreimann/elaborate-on-regexp

Motivate and explain regular expression rules.
This commit is contained in:
Vincent Demeester 2017-03-03 10:09:30 +01:00 committed by GitHub
commit 291ca860af

View file

@ -85,13 +85,17 @@ Frontends can be defined using the following rules:
- `PathStrip`: Same as `Path` but strip the given prefix from the request URL's Path.
- `PathPrefix`: PathPrefix adds a matcher for the URL path prefixes. This matches if the given template is a prefix of the full URL path.
- `PathPrefixStrip`: Same as `PathPrefix` but strip the given prefix from the request URL's Path.
- `AddPrefix` : Add prefix from the request URL's Path.
- `AddPrefix`: Add prefix to the request URL's Path.
You can use multlple values for a rule by separating them with `,`.
You can use multiple values for a rule by separating them with `,`.
You can use multiple rules by separating them by `;`.
You can optionally enable `passHostHeader` to forward client `Host` header to the backend.
In order to use path regular expressions, you must declare an arbitrarily named variable followed by the colon-separated regular expression, all enclosed in curly braces. Any pattern supported by [Go's regexp package](https://golang.org/pkg/regexp/) may be used. Example: `/posts/{id:[0-9]+}`.
(Note that the variable has no special meaning; however, it is required by gorilla/mux which embeds the regular expression and defines the syntax.)
Here is an example of frontends definition:
```toml