@@ -152,7 +152,7 @@ type HTTPRouteRule struct {
152
152
//
153
153
// * The oldest Route based on creation timestamp.
154
154
// * The Route appearing first in alphabetical order by
155
- // "< namespace>/< name> ".
155
+ // "{ namespace}/{ name} ".
156
156
//
157
157
// If ties still exist within the Route that has been given precedence,
158
158
// matching precedence MUST be granted to the first matching rule meeting
@@ -227,11 +227,10 @@ const (
227
227
// Matches based on a URL path prefix split by `/`. Matching is
228
228
// case sensitive and done on a path element by element basis. A
229
229
// path element refers to the list of labels in the path split by
230
- // the `/` separator. A request is a match for path _p_ if every
231
- // _p_ is an element-wise prefix of the request path.
230
+ // the `/` separator. When specified, a trailing `/` is ignored.
232
231
//
233
- // For example, `/abc`, `/abc/` and `/abc/def` match the prefix
234
- // `/abc`, but `/abcd` does not.
232
+ // For example. the paths `/abc`, `/abc/`, and `/abc/def` would all match
233
+ // the prefix `/abc`, but the path `/abcd` would not.
235
234
//
236
235
// "PathPrefix" is semantically equivalent to the "Prefix" path type in the
237
236
// Kubernetes Ingress API.
@@ -495,6 +494,8 @@ type HTTPRouteFilter struct {
495
494
// that filter MUST receive a HTTP error response.
496
495
//
497
496
// +unionDiscriminator
497
+ // +kubebuilder:validation:Enum=RequestHeaderModifier;RequestMirror;RequestRedirect;ExtensionRef
498
+ // <gateway:experimental:validation:Enum=RequestHeaderModifier;RequestMirror;RequestRedirect;URLRewrite;ExtensionRef>
498
499
Type HTTPRouteFilterType `json:"type"`
499
500
500
501
// RequestHeaderModifier defines a schema for a filter that modifies request
@@ -522,6 +523,13 @@ type HTTPRouteFilter struct {
522
523
// +optional
523
524
RequestRedirect * HTTPRequestRedirectFilter `json:"requestRedirect,omitempty"`
524
525
526
+ // URLRewrite defines a schema for a filter that modifies a request during forwarding.
527
+ // Support: Extended
528
+ //
529
+ // <gateway:experimental>
530
+ // +optional
531
+ URLRewrite * HTTPURLRewriteFilter `json:"urlRewrite,omitempty"`
532
+
525
533
// ExtensionRef is an optional, implementation-specific extension to the
526
534
// "filter" behavior. For example, resource "myroutefilter" in group
527
535
// "networking.example.net"). ExtensionRef MUST NOT be used for core and
@@ -534,7 +542,6 @@ type HTTPRouteFilter struct {
534
542
}
535
543
536
544
// HTTPRouteFilterType identifies a type of HTTPRoute filter.
537
- // +kubebuilder:validation:Enum=RequestHeaderModifier;RequestMirror;RequestRedirect;ExtensionRef
538
545
type HTTPRouteFilterType string
539
546
540
547
const (
@@ -548,13 +555,26 @@ const (
548
555
549
556
// HTTPRouteFilterRequestRedirect can be used to redirect a request to
550
557
// another location. This filter can also be used for HTTP to HTTPS
551
- // redirects.
558
+ // redirects. This may not be used on the same Route rule or BackendRef as a
559
+ // URLRewrite filter.
552
560
//
553
561
// Support in HTTPRouteRule: Core
554
562
//
555
563
// Support in HTTPBackendRef: Extended
556
564
HTTPRouteFilterRequestRedirect HTTPRouteFilterType = "RequestRedirect"
557
565
566
+ // HTTPRouteFilterURLRewrite can be used to modify a request during
567
+ // forwarding. At most one of these filters may be used on a Route rule.
568
+ // This may not be used on the same Route rule or BackendRef as a
569
+ // RequestRedirect filter.
570
+ //
571
+ // Support in HTTPRouteRule: Extended
572
+ //
573
+ // Support in HTTPBackendRef: Extended
574
+ //
575
+ // <gateway:experimental>
576
+ HTTPRouteFilterURLRewrite HTTPRouteFilterType = "URLRewrite"
577
+
558
578
// HTTPRouteFilterRequestMirror can be used to mirror HTTP requests to a
559
579
// different backend. The responses from this backend MUST be ignored by
560
580
// the Gateway.
@@ -664,7 +684,42 @@ type HTTPRequestHeaderFilter struct {
664
684
Remove []string `json:"remove,omitempty"`
665
685
}
666
686
667
- // HTTPRequestRedirectFilter defines configuration for the RequestRedirect filter.
687
+ // HTTPPathModifierType defines the type of path redirect.
688
+ type HTTPPathModifierType string
689
+
690
+ const (
691
+ // This type of modifier indicates that the complete path will be replaced
692
+ // by the path redirect value.
693
+ AbsoluteHTTPPathModifier HTTPPathModifierType = "Absolute"
694
+
695
+ // This type of modifier indicates that any prefix path matches will be
696
+ // replaced by the substitution value. For example, a path with a prefix
697
+ // match of "/foo" and a ReplacePrefixMatch substitution of "/bar" will have
698
+ // the "/foo" prefix replaced with "/bar" in matching requests.
699
+ PrefixMatchHTTPPathModifier HTTPPathModifierType = "ReplacePrefixMatch"
700
+ )
701
+
702
+ // HTTPPathModifier defines configuration for path modifiers.
703
+ // <gateway:experimental>
704
+ type HTTPPathModifier struct {
705
+ // Type defines the type of path modifier.
706
+ //
707
+ // <gateway:experimental>
708
+ // +kubebuilder:validation:Enum=Absolute;ReplacePrefixMatch
709
+ Type HTTPPathModifierType `json:"type"`
710
+
711
+ // Substitution defines the HTTP path value to substitute. An empty value
712
+ // ("") indicates that the portion of the path to be changed should be
713
+ // removed from the resulting path. For example, a request to "/foo/bar"
714
+ // with a prefix match of "/foo" would be modified to "/bar".
715
+ //
716
+ // <gateway:experimental>
717
+ // +kubebuilder:validation:MaxLength=1024
718
+ Substitution string `json:"substitution"`
719
+ }
720
+
721
+ // HTTPRequestRedirect defines a filter that redirects a request. This filter
722
+ // MUST not be used on the same Route rule as a HTTPURLRewrite filter.
668
723
type HTTPRequestRedirectFilter struct {
669
724
// Scheme is the scheme to be used in the value of the `Location`
670
725
// header in the response.
@@ -685,6 +740,16 @@ type HTTPRequestRedirectFilter struct {
685
740
// +optional
686
741
Hostname * PreciseHostname `json:"hostname,omitempty"`
687
742
743
+ // Path defines parameters used to modify the path of the incoming request.
744
+ // The modified path is then used to construct the `Location` header. When
745
+ // empty, the request path is used as-is.
746
+ //
747
+ // Support: Extended
748
+ //
749
+ // <gateway:experimental>
750
+ // +optional
751
+ Path * HTTPPathModifier `json:"path,omitempty"`
752
+
688
753
// Port is the port to be used in the value of the `Location`
689
754
// header in the response.
690
755
// When empty, port (if specified) of the request is used.
@@ -704,6 +769,31 @@ type HTTPRequestRedirectFilter struct {
704
769
StatusCode * int `json:"statusCode,omitempty"`
705
770
}
706
771
772
+ // HTTPURLRewriteFilter defines a filter that modifies a request during
773
+ // forwarding. At most one of these filters may be used on a Route rule. This
774
+ // may not be used on the same Route rule as a HTTPRequestRedirect filter.
775
+ //
776
+ // <gateway:experimental>
777
+ // Support: Extended
778
+ type HTTPURLRewriteFilter struct {
779
+ // Hostname is the value to be used to replace the Host header value during
780
+ // forwarding.
781
+ //
782
+ // Support: Extended
783
+ //
784
+ // <gateway:experimental>
785
+ // +optional
786
+ Hostname * Hostname `json:"hostname,omitempty"`
787
+
788
+ // Path defines a path rewrite.
789
+ //
790
+ // Support: Extended
791
+ //
792
+ // <gateway:experimental>
793
+ // +optional
794
+ Path * HTTPPathModifier `json:"path,omitempty"`
795
+ }
796
+
707
797
// HTTPRequestMirrorFilter defines configuration for the RequestMirror filter.
708
798
type HTTPRequestMirrorFilter struct {
709
799
// BackendRef references a resource where mirrored requests are sent.
@@ -738,7 +828,7 @@ type HTTPBackendRef struct {
738
828
//
739
829
// If there is a cross-namespace reference to an *existing* object
740
830
// that is not covered by a ReferencePolicy, the controller must ensure the
741
- // "ResolvedRefs" condition on the Route is set to `status: true `,
831
+ // "ResolvedRefs" condition on the Route is set to `status: False `,
742
832
// with the "RefNotPermitted" reason and not configure this backend in the
743
833
// underlying implementation.
744
834
//
0 commit comments