Skip to content

Commit 1f5c0fa

Browse files
committed
Adding QueryParam matching to HTTPRoute
1 parent a122b1f commit 1f5c0fa

File tree

4 files changed

+125
-0
lines changed

4 files changed

+125
-0
lines changed

apis/v1alpha1/httproute_types.go

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,23 @@ const (
270270
HeaderMatchImplementationSpecific HeaderMatchType = "ImplementationSpecific"
271271
)
272272

273+
// QueryParamMatchType specifies the semantics of how HTTP query parameter
274+
// values should be compared. Valid QueryParamMatchType values are:
275+
//
276+
// * "Exact"
277+
// * "RegularExpression"
278+
// * "ImplementationSpecific"
279+
//
280+
// +kubebuilder:validation:Enum=Exact;RegularExpression;ImplementationSpecific
281+
type QueryParamMatchType string
282+
283+
// QueryParamMatchType constants.
284+
const (
285+
QueryParamMatchExact QueryParamMatchType = "Exact"
286+
QueryParamMatchRegularExpression QueryParamMatchType = "RegularExpression"
287+
QueryParamMatchImplementationSpecific QueryParamMatchType = "ImplementationSpecific"
288+
)
289+
273290
// HTTPPathMatch describes how to select a HTTP route by matching the HTTP request path.
274291
type HTTPPathMatch struct {
275292
// Type specifies how to match against the path Value.
@@ -326,6 +343,38 @@ type HTTPHeaderMatch struct {
326343
Values map[string]string `json:"values"`
327344
}
328345

346+
// HTTPQueryParamMatch describes how to select a HTTP route by matching HTTP
347+
// query parameters.
348+
type HTTPQueryParamMatch struct {
349+
// Type specifies how to match against the value of the query parameter.
350+
//
351+
// Support: Extended (Exact)
352+
//
353+
// Support: Custom (RegularExpression, ImplementationSpecific)
354+
//
355+
// Since RegularExpression QueryParamMatchType has custom conformance,
356+
// implementations can support POSIX, PCRE or any other dialects of regular
357+
// expressions. Please read the implementation's documentation to determine
358+
// the supported dialect.
359+
//
360+
// HTTP query parameter matching MUST be case-sensitive for both keys and
361+
// values.
362+
//
363+
// +optional
364+
// +kubebuilder:default=Exact
365+
Type *QueryParamMatchType `json:"type,omitempty"`
366+
367+
// Values is a map of HTTP query parameters to be matched. It MUST contain
368+
// at least one entry.
369+
//
370+
// The query parameter name to match is the map key, and the value of the
371+
// query parameter is the map value.
372+
//
373+
// Multiple match values are ANDed together, meaning, a request must match
374+
// all the specified query parameters to select the route.
375+
Values map[string]string `json:"values"`
376+
}
377+
329378
// HTTPRouteMatch defines the predicate used to match requests to a given
330379
// action. Multiple match types are ANDed together, i.e. the match will
331380
// evaluate to true only if all conditions are satisfied.
@@ -354,6 +403,11 @@ type HTTPRouteMatch struct {
354403
// +optional
355404
Headers *HTTPHeaderMatch `json:"headers,omitempty"`
356405

406+
// QueryParams specifies a HTTP query parameter matcher.
407+
//
408+
// +optional
409+
QueryParams *HTTPQueryParamMatch `json:"queryParams,omitempty"`
410+
357411
// ExtensionRef is an optional, implementation-specific extension to the
358412
// "match" behavior. For example, resource "myroutematcher" in group
359413
// "networking.acme.io". If the referent cannot be found, the rule is not

apis/v1alpha1/zz_generated.deepcopy.go

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/networking.x-k8s.io_httproutes.yaml

Lines changed: 35 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/basic-http.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ spec:
4848
type: Exact
4949
values:
5050
magic: foo
51+
queryParams:
52+
type: Exact
53+
values:
54+
great: example
5155
path:
5256
type: Prefix
5357
value: /some/thing

0 commit comments

Comments
 (0)