Skip to content

Commit

Permalink
Align path prefix matching with Ingress.
Browse files Browse the repository at this point in the history
Explicitly align path prefix matching with the Ingress API by specifying
it as an prefix of path elements, not a prefix of bytes.

This fixes #866.

Signed-off-by: James Peach <jpeach@apache.org>
  • Loading branch information
jpeach committed Sep 21, 2021
1 parent c5c4e07 commit 89f4afc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
34 changes: 22 additions & 12 deletions apis/v1alpha2/httproute_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,18 +214,33 @@ type HTTPRouteRule struct {
//
// Prefix and Exact paths must be syntactically valid:
//
// - Must begin with the '/' character
// - Must not contain consecutive '/' characters (e.g. /foo///, //).
// - For prefix paths, a trailing '/' character in the Path is ignored,
// e.g. /abc and /abc/ specify the same match.
// - Must begin with the `/` character
// - Must not contain consecutive `/` characters (e.g. `/foo///`, `//`).
//
// +kubebuilder:validation:Enum=Exact;Prefix;RegularExpression
type PathMatchType string

// PathMatchType constants.
const (
PathMatchExact PathMatchType = "Exact"
PathMatchPrefix PathMatchType = "Prefix"
// Matches based on a URL path prefix split by `/`. Matching is
// case sensitive and done on a path element by element basis. A
// path element refers to the list of labels in the path split by
// the `/` separator. A request is a match for path _p_ if every
// _p_ is an element-wise prefix of the request path.
//
// For example, `/abc`, `/abc/` and `/abc/def` match the prefix
// `/abc`, but `/abcd` does not.
PathMatchExact PathMatchType = "Exact"

// Matches the URL path exactly and with case sensitivity.
PathMatchPrefix PathMatchType = "Prefix"

// Matches if the URL path matches the given regular expression with
// case sensitivity.
//
// Since `"RegularExpression"` has custom conformance, implementations
// can support POSIX, PCRE, RE2 or any other regular expression dialect.
// Please read the implementation's documentation to determine the supported
// dialect.
PathMatchRegularExpression PathMatchType = "RegularExpression"
)

Expand All @@ -237,11 +252,6 @@ type HTTPPathMatch struct {
//
// Support: Custom (RegularExpression)
//
// Since RegularExpression PathType has custom conformance, implementations
// can support POSIX, PCRE or any other dialects of regular expressions.
// Please read the implementation's documentation to determine the supported
// dialect.
//
// +optional
// +kubebuilder:default=Prefix
Type *PathMatchType `json:"type,omitempty"`
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 89f4afc

Please sign in to comment.