1 /* 2 Adapted from https://github.com/kubernetes-sigs/gateway-api/blob/main/apis/v1alpha2/httproute_types.go 3 Copyright 2020 The Kubernetes Authors. 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 http://www.apache.org/licenses/LICENSE-2.0 8 Unless required by applicable law or agreed to in writing, software 9 distributed under the License is distributed on an "AS IS" BASIS, 10 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 See the License for the specific language governing permissions and 12 limitations under the License. 13 */ 14 15 package v1alpha1 16 17 import ( 18 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 19 gatewayapiv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" 20 ) 21 22 // +genclient 23 // +genclient:noStatus 24 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 25 // +groupName=policy.linkerd.io 26 27 // HTTPRoute provides a way to route HTTP requests. This includes the capability 28 // to match requests by hostname, path, header, or query param. Filters can be 29 // used to specify additional processing steps. Backends specify where matching 30 // requests should be routed. 31 type HTTPRoute struct { 32 metav1.TypeMeta `json:",inline"` 33 metav1.ObjectMeta `json:"metadata,omitempty"` 34 35 // Spec defines the desired state of HTTPRoute. 36 Spec HTTPRouteSpec `json:"spec"` 37 38 // Status defines the current state of HTTPRoute. 39 Status HTTPRouteStatus `json:"status,omitempty"` 40 } 41 42 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 43 44 // HTTPRouteList contains a list of HTTPRoute. 45 type HTTPRouteList struct { 46 metav1.TypeMeta `json:",inline"` 47 metav1.ListMeta `json:"metadata,omitempty"` 48 Items []HTTPRoute `json:"items"` 49 } 50 51 // HTTPRouteSpec defines the desired state of HTTPRoute 52 type HTTPRouteSpec struct { 53 gatewayapiv1alpha2.CommonRouteSpec `json:",inline"` 54 55 // Hostnames defines a set of hostname that should match against the HTTP 56 // Host header to select a HTTPRoute to process the request. This matches 57 // the RFC 1123 definition of a hostname with 2 notable exceptions: 58 // 59 // 1. IPs are not allowed. 60 // 2. A hostname may be prefixed with a wildcard label (`*.`). The wildcard 61 // label must appear by itself as the first label. 62 // 63 // If a hostname is specified by both the Listener and HTTPRoute, there 64 // must be at least one intersecting hostname for the HTTPRoute to be 65 // attached to the Listener. For example: 66 // 67 // * A Listener with `test.example.com` as the hostname matches HTTPRoutes 68 // that have either not specified any hostnames, or have specified at 69 // least one of `test.example.com` or `*.example.com`. 70 // * A Listener with `*.example.com` as the hostname matches HTTPRoutes 71 // that have either not specified any hostnames or have specified at least 72 // one hostname that matches the Listener hostname. For example, 73 // `*.example.com`, `test.example.com`, and `foo.test.example.com` would 74 // all match. On the other hand, `example.com` and `test.example.net` would 75 // not match. 76 // 77 // Hostnames that are prefixed with a wildcard label (`*.`) are interpreted 78 // as a suffix match. That means that a match for `*.example.com` would match 79 // both `test.example.com`, and `foo.test.example.com`, but not `example.com`. 80 // 81 // If both the Listener and HTTPRoute have specified hostnames, any 82 // HTTPRoute hostnames that do not match the Listener hostname MUST be 83 // ignored. For example, if a Listener specified `*.example.com`, and the 84 // HTTPRoute specified `test.example.com` and `test.example.net`, 85 // `test.example.net` must not be considered for a match. 86 // 87 // If both the Listener and HTTPRoute have specified hostnames, and none 88 // match with the criteria above, then the HTTPRoute is not accepted. The 89 // implementation must raise an 'Accepted' Condition with a status of 90 // `False` in the corresponding RouteParentStatus. 91 // 92 // Support: Core 93 // 94 // +optional 95 // +kubebuilder:validation:MaxItems=16 96 Hostnames []gatewayapiv1alpha2.Hostname `json:"hostnames,omitempty"` 97 98 // Rules are a list of HTTP matchers, filters and actions. 99 // 100 // +optional 101 // +kubebuilder:validation:MaxItems=16 102 // +kubebuilder:default={{matches: {{path: {type: "PathPrefix", value: "/"}}}}} 103 Rules []HTTPRouteRule `json:"rules,omitempty"` 104 } 105 106 // HTTPRouteRule defines semantics for matching an HTTP request based on 107 // conditions (matches), processing it (filters), and forwarding the request to 108 // an API object (backendRefs). 109 type HTTPRouteRule struct { 110 // Matches define conditions used for matching the rule against incoming 111 // HTTP requests. Each match is independent, i.e. this rule will be matched 112 // if **any** one of the matches is satisfied. 113 // 114 // For example, take the following matches configuration: 115 // 116 // ``` 117 // matches: 118 // - path: 119 // value: "/foo" 120 // headers: 121 // - name: "version" 122 // value: "v2" 123 // - path: 124 // value: "/v2/foo" 125 // ``` 126 // 127 // For a request to match against this rule, a request must satisfy 128 // EITHER of the two conditions: 129 // 130 // - path prefixed with `/foo` AND contains the header `version: v2` 131 // - path prefix of `/v2/foo` 132 // 133 // See the documentation for HTTPRouteMatch on how to specify multiple 134 // match conditions that should be ANDed together. 135 // 136 // If no matches are specified, the default is a prefix 137 // path match on "/", which has the effect of matching every 138 // HTTP request. 139 // 140 // Proxy or Load Balancer routing configuration generated from HTTPRoutes 141 // MUST prioritize rules based on the following criteria, continuing on 142 // ties. Precedence must be given to the Rule with the largest number 143 // of: 144 // 145 // * Characters in a matching non-wildcard hostname. 146 // * Characters in a matching hostname. 147 // * Characters in a matching path. 148 // * Header matches. 149 // * Query param matches. 150 // 151 // If ties still exist across multiple Routes, matching precedence MUST be 152 // determined in order of the following criteria, continuing on ties: 153 // 154 // * The oldest Route based on creation timestamp. 155 // * The Route appearing first in alphabetical order by 156 // "{namespace}/{name}". 157 // 158 // If ties still exist within the Route that has been given precedence, 159 // matching precedence MUST be granted to the first matching rule meeting 160 // the above criteria. 161 // 162 // When no rules matching a request have been successfully attached to the 163 // parent a request is coming from, a HTTP 404 status code MUST be returned. 164 // 165 // +optional 166 // +kubebuilder:validation:MaxItems=8 167 // +kubebuilder:default={{path:{ type: "PathPrefix", value: "/"}}} 168 Matches []HTTPRouteMatch `json:"matches,omitempty"` 169 170 // Filters define the filters that are applied to requests that match 171 // this rule. 172 // 173 // The effects of ordering of multiple behaviors are currently unspecified. 174 // This can change in the future based on feedback during the alpha stage. 175 // 176 // Conformance-levels at this level are defined based on the type of filter: 177 // 178 // - ALL core filters MUST be supported by all implementations. 179 // - Implementers are encouraged to support extended filters. 180 // - Implementation-specific custom filters have no API guarantees across 181 // implementations. 182 // 183 // Specifying a core filter multiple times has unspecified or custom 184 // conformance. 185 // 186 // All filters are expected to be compatible with each other except for the 187 // URLRewrite and RequestRedirect filters, which may not be combined. If an 188 // implementation can not support other combinations of filters, they must clearly 189 // document that limitation. In all cases where incompatible or unsupported 190 // filters are specified, implementations MUST add a warning condition to status. 191 // 192 // Support: Core 193 // 194 // +optional 195 // +kubebuilder:validation:MaxItems=16 196 Filters []HTTPRouteFilter `json:"filters,omitempty"` 197 } 198 199 // PathMatchType specifies the semantics of how HTTP paths should be compared. 200 // Valid PathMatchType values are: 201 // 202 // * "Exact" 203 // * "PathPrefix" 204 // * "RegularExpression" 205 // 206 // PathPrefix and Exact paths must be syntactically valid: 207 // 208 // - Must begin with the `/` character 209 // - Must not contain consecutive `/` characters (e.g. `/foo///`, `//`). 210 // 211 // Note that values may be added to this enum, implementations 212 // must ensure that unknown values will not cause a crash. 213 // 214 // Unknown values here must result in the implementation setting the 215 // Attached Condition for the Route to `status: False`, with a 216 // Reason of `UnsupportedValue`. 217 // 218 // +kubebuilder:validation:Enum=Exact;PathPrefix;RegularExpression 219 type PathMatchType string 220 221 const ( 222 // Matches the URL path exactly and with case sensitivity. 223 PathMatchExact PathMatchType = "Exact" 224 225 // Matches based on a URL path prefix split by `/`. Matching is 226 // case sensitive and done on a path element by element basis. A 227 // path element refers to the list of labels in the path split by 228 // the `/` separator. When specified, a trailing `/` is ignored. 229 // 230 // For example, the paths `/abc`, `/abc/`, and `/abc/def` would all match 231 // the prefix `/abc`, but the path `/abcd` would not. 232 // 233 // "PathPrefix" is semantically equivalent to the "Prefix" path type in the 234 // Kubernetes Ingress API. 235 PathMatchPathPrefix PathMatchType = "PathPrefix" 236 237 // Matches if the URL path matches the given regular expression with 238 // case sensitivity. 239 // 240 // Since `"RegularExpression"` has custom conformance, implementations 241 // can support POSIX, PCRE, RE2 or any other regular expression dialect. 242 // Please read the implementation's documentation to determine the supported 243 // dialect. 244 PathMatchRegularExpression PathMatchType = "RegularExpression" 245 ) 246 247 // HTTPPathMatch describes how to select a HTTP route by matching the HTTP request path. 248 type HTTPPathMatch struct { 249 // Type specifies how to match against the path Value. 250 // 251 // Support: Core (Exact, PathPrefix) 252 // 253 // Support: Custom (RegularExpression) 254 // 255 // +optional 256 // +kubebuilder:default=PathPrefix 257 Type *PathMatchType `json:"type,omitempty"` 258 259 // Value of the HTTP path to match against. 260 // 261 // +optional 262 // +kubebuilder:default="/" 263 // +kubebuilder:validation:MaxLength=1024 264 Value *string `json:"value,omitempty"` 265 } 266 267 // HeaderMatchType specifies the semantics of how HTTP header values should be 268 // compared. Valid HeaderMatchType values are: 269 // 270 // * "Exact" 271 // * "RegularExpression" 272 // 273 // Note that values may be added to this enum, implementations 274 // must ensure that unknown values will not cause a crash. 275 // 276 // Unknown values here must result in the implementation setting the 277 // Attached Condition for the Route to `status: False`, with a 278 // Reason of `UnsupportedValue`. 279 // 280 // +kubebuilder:validation:Enum=Exact;RegularExpression 281 type HeaderMatchType string 282 283 // HeaderMatchType constants. 284 const ( 285 HeaderMatchExact HeaderMatchType = "Exact" 286 HeaderMatchRegularExpression HeaderMatchType = "RegularExpression" 287 ) 288 289 // HTTPHeaderName is the name of an HTTP header. 290 // 291 // Valid values include: 292 // 293 // * "Authorization" 294 // * "Set-Cookie" 295 // 296 // Invalid values include: 297 // 298 // * ":method" - ":" is an invalid character. This means that HTTP/2 pseudo 299 // headers are not currently supported by this type. 300 // * "/invalid" - "/" is an invalid character 301 // 302 // +kubebuilder:validation:MinLength=1 303 // +kubebuilder:validation:MaxLength=256 304 // +kubebuilder:validation:Pattern=`^[A-Za-z0-9!#$%&'*+\-.^_\x60|~]+$` 305 type HTTPHeaderName string 306 307 // HTTPHeaderMatch describes how to select a HTTP route by matching HTTP request 308 // headers. 309 type HTTPHeaderMatch struct { 310 // Type specifies how to match against the value of the header. 311 // 312 // Support: Core (Exact) 313 // 314 // Support: Custom (RegularExpression) 315 // 316 // Since RegularExpression HeaderMatchType has custom conformance, 317 // implementations can support POSIX, PCRE or any other dialects of regular 318 // expressions. Please read the implementation's documentation to determine 319 // the supported dialect. 320 // 321 // +optional 322 // +kubebuilder:default=Exact 323 Type *HeaderMatchType `json:"type,omitempty"` 324 325 // Name is the name of the HTTP Header to be matched. Name matching MUST be 326 // case insensitive. (See https://tools.ietf.org/html/rfc7230#section-3.2). 327 // 328 // If multiple entries specify equivalent header names, only the first 329 // entry with an equivalent name MUST be considered for a match. Subsequent 330 // entries with an equivalent header name MUST be ignored. Due to the 331 // case-insensitivity of header names, "foo" and "Foo" are considered 332 // equivalent. 333 // 334 // When a header is repeated in an HTTP request, it is 335 // implementation-specific behavior as to how this is represented. 336 // Generally, proxies should follow the guidance from the RFC: 337 // https://www.rfc-editor.org/rfc/rfc7230.html#section-3.2.2 regarding 338 // processing a repeated header, with special handling for "Set-Cookie". 339 Name HTTPHeaderName `json:"name"` 340 341 // Value is the value of HTTP Header to be matched. 342 // 343 // +kubebuilder:validation:MinLength=1 344 // +kubebuilder:validation:MaxLength=4096 345 Value string `json:"value"` 346 } 347 348 // QueryParamMatchType specifies the semantics of how HTTP query parameter 349 // values should be compared. Valid QueryParamMatchType values are: 350 // 351 // * "Exact" 352 // * "RegularExpression" 353 // 354 // Note that values may be added to this enum, implementations 355 // must ensure that unknown values will not cause a crash. 356 // 357 // Unknown values here must result in the implementation setting the 358 // Attached Condition for the Route to `status: False`, with a 359 // Reason of `UnsupportedValue`. 360 // 361 // +kubebuilder:validation:Enum=Exact;RegularExpression 362 type QueryParamMatchType string 363 364 // QueryParamMatchType constants. 365 const ( 366 QueryParamMatchExact QueryParamMatchType = "Exact" 367 QueryParamMatchRegularExpression QueryParamMatchType = "RegularExpression" 368 ) 369 370 // HTTPQueryParamMatch describes how to select a HTTP route by matching HTTP 371 // query parameters. 372 type HTTPQueryParamMatch struct { 373 // Type specifies how to match against the value of the query parameter. 374 // 375 // Support: Extended (Exact) 376 // 377 // Support: Custom (RegularExpression) 378 // 379 // Since RegularExpression QueryParamMatchType has custom conformance, 380 // implementations can support POSIX, PCRE or any other dialects of regular 381 // expressions. Please read the implementation's documentation to determine 382 // the supported dialect. 383 // 384 // +optional 385 // +kubebuilder:default=Exact 386 Type *QueryParamMatchType `json:"type,omitempty"` 387 388 // Name is the name of the HTTP query param to be matched. This must be an 389 // exact string match. (See 390 // https://tools.ietf.org/html/rfc7230#section-2.7.3). 391 // 392 // If multiple entries specify equivalent query param names, only the first 393 // entry with an equivalent name MUST be considered for a match. Subsequent 394 // entries with an equivalent query param name MUST be ignored. 395 // 396 // +kubebuilder:validation:MinLength=1 397 // +kubebuilder:validation:MaxLength=256 398 Name string `json:"name"` 399 400 // Value is the value of HTTP query param to be matched. 401 // 402 // +kubebuilder:validation:MinLength=1 403 // +kubebuilder:validation:MaxLength=1024 404 Value string `json:"value"` 405 } 406 407 // HTTPMethod describes how to select a HTTP route by matching the HTTP 408 // method as defined by 409 // [RFC 7231](https://datatracker.ietf.org/doc/html/rfc7231#section-4) and 410 // [RFC 5789](https://datatracker.ietf.org/doc/html/rfc5789#section-2). 411 // The value is expected in upper case. 412 // 413 // Note that values may be added to this enum, implementations 414 // must ensure that unknown values will not cause a crash. 415 // 416 // Unknown values here must result in the implementation setting the 417 // Attached Condition for the Route to `status: False`, with a 418 // Reason of `UnsupportedValue`. 419 // 420 // +kubebuilder:validation:Enum=GET;HEAD;POST;PUT;DELETE;CONNECT;OPTIONS;TRACE;PATCH 421 type HTTPMethod string 422 423 const ( 424 HTTPMethodGet HTTPMethod = "GET" 425 HTTPMethodHead HTTPMethod = "HEAD" 426 HTTPMethodPost HTTPMethod = "POST" 427 HTTPMethodPut HTTPMethod = "PUT" 428 HTTPMethodDelete HTTPMethod = "DELETE" 429 HTTPMethodConnect HTTPMethod = "CONNECT" 430 HTTPMethodOptions HTTPMethod = "OPTIONS" 431 HTTPMethodTrace HTTPMethod = "TRACE" 432 HTTPMethodPatch HTTPMethod = "PATCH" 433 ) 434 435 // HTTPRouteMatch defines the predicate used to match requests to a given 436 // action. Multiple match types are ANDed together, i.e. the match will 437 // evaluate to true only if all conditions are satisfied. 438 // 439 // For example, the match below will match a HTTP request only if its path 440 // starts with `/foo` AND it contains the `version: v1` header: 441 // 442 // ``` 443 // match: 444 // path: 445 // value: "/foo" 446 // headers: 447 // - name: "version" 448 // value "v1" 449 // ``` 450 type HTTPRouteMatch struct { 451 // Path specifies a HTTP request path matcher. If this field is not 452 // specified, a default prefix match on the "/" path is provided. 453 // 454 // +optional 455 // +kubebuilder:default={type: "PathPrefix", value: "/"} 456 Path *HTTPPathMatch `json:"path,omitempty"` 457 458 // Headers specifies HTTP request header matchers. Multiple match values are 459 // ANDed together, meaning, a request must match all the specified headers 460 // to select the route. 461 // 462 // +listType=map 463 // +listMapKey=name 464 // +optional 465 // +kubebuilder:validation:MaxItems=16 466 Headers []HTTPHeaderMatch `json:"headers,omitempty"` 467 468 // QueryParams specifies HTTP query parameter matchers. Multiple match 469 // values are ANDed together, meaning, a request must match all the 470 // specified query parameters to select the route. 471 // 472 // +listType=map 473 // +listMapKey=name 474 // +optional 475 // +kubebuilder:validation:MaxItems=16 476 QueryParams []HTTPQueryParamMatch `json:"queryParams,omitempty"` 477 478 // Method specifies HTTP method matcher. 479 // When specified, this route will be matched only if the request has the 480 // specified method. 481 // 482 // Support: Extended 483 // 484 // +optional 485 Method *HTTPMethod `json:"method,omitempty"` 486 } 487 488 // HTTPRouteFilter defines processing steps that must be completed during the 489 // request or response lifecycle. HTTPRouteFilters are meant as an extension 490 // point to express processing that may be done in Gateway implementations. Some 491 // examples include request or response modification, implementing 492 // authentication strategies, rate-limiting, and traffic shaping. API 493 // guarantee/conformance is defined based on the type of the filter. 494 type HTTPRouteFilter struct { 495 // Type identifies the type of filter to apply. As with other API fields, 496 // types are classified into three conformance levels: 497 // 498 // - Core: Filter types and their corresponding configuration defined by 499 // "Support: Core" in this package, e.g. "RequestHeaderModifier". All 500 // implementations must support core filters. 501 // 502 // - Extended: Filter types and their corresponding configuration defined by 503 // "Support: Extended" in this package, e.g. "RequestMirror". Implementers 504 // are encouraged to support extended filters. 505 // 506 // - Custom: Filters that are defined and supported by specific vendors. 507 // In the future, filters showing convergence in behavior across multiple 508 // implementations will be considered for inclusion in extended or core 509 // conformance levels. Filter-specific configuration for such filters 510 // is specified using the ExtensionRef field. `Type` should be set to 511 // "ExtensionRef" for custom filters. 512 // 513 // Implementers are encouraged to define custom implementation types to 514 // extend the core API with implementation-specific behavior. 515 // 516 // If a reference to a custom filter type cannot be resolved, the filter 517 // MUST NOT be skipped. Instead, requests that would have been processed by 518 // that filter MUST receive a HTTP error response. 519 // 520 // Note that values may be added to this enum, implementations 521 // must ensure that unknown values will not cause a crash. 522 // 523 // Unknown values here must result in the implementation setting the 524 // Attached Condition for the Route to `status: False`, with a 525 // Reason of `UnsupportedValue`. 526 // 527 // +unionDiscriminator 528 // +kubebuilder:validation:Enum=RequestHeaderModifier;RequestMirror;RequestRedirect;ExtensionRef 529 // <gateway:experimental:validation:Enum=RequestHeaderModifier;RequestMirror;RequestRedirect;URLRewrite;ExtensionRef> 530 Type HTTPRouteFilterType `json:"type"` 531 532 // RequestHeaderModifier defines a schema for a filter that modifies request 533 // headers. 534 // 535 // Support: Core 536 // 537 // +optional 538 RequestHeaderModifier *HTTPRequestHeaderFilter `json:"requestHeaderModifier,omitempty"` 539 540 // RequestRedirect defines a schema for a filter that responds to the 541 // request with an HTTP redirection. 542 // 543 // Support: Core 544 // 545 // +optional 546 RequestRedirect *HTTPRequestRedirectFilter `json:"requestRedirect,omitempty"` 547 } 548 549 // HTTPRouteFilterType identifies a type of HTTPRoute filter. 550 type HTTPRouteFilterType string 551 552 const ( 553 // HTTPRouteFilterRequestHeaderModifier can be used to add or remove an HTTP 554 // header from an HTTP request before it is sent to the upstream target. 555 // 556 // Support in HTTPRouteRule: Core 557 // 558 // Support in HTTPBackendRef: Extended 559 HTTPRouteFilterRequestHeaderModifier HTTPRouteFilterType = "RequestHeaderModifier" 560 561 // HTTPRouteFilterRequestRedirect can be used to redirect a request to 562 // another location. This filter can also be used for HTTP to HTTPS 563 // redirects. This may not be used on the same Route rule or BackendRef as a 564 // URLRewrite filter. 565 // 566 // Support in HTTPRouteRule: Core 567 // 568 // Support in HTTPBackendRef: Extended 569 HTTPRouteFilterRequestRedirect HTTPRouteFilterType = "RequestRedirect" 570 ) 571 572 // HTTPHeader represents an HTTP Header name and value as defined by RFC 7230. 573 type HTTPHeader struct { 574 // Name is the name of the HTTP Header to be matched. Name matching MUST be 575 // case insensitive. (See https://tools.ietf.org/html/rfc7230#section-3.2). 576 // 577 // If multiple entries specify equivalent header names, the first entry with 578 // an equivalent name MUST be considered for a match. Subsequent entries 579 // with an equivalent header name MUST be ignored. Due to the 580 // case-insensitivity of header names, "foo" and "Foo" are considered 581 // equivalent. 582 Name HTTPHeaderName `json:"name"` 583 584 // Value is the value of HTTP Header to be matched. 585 // 586 // +kubebuilder:validation:MinLength=1 587 // +kubebuilder:validation:MaxLength=4096 588 Value string `json:"value"` 589 } 590 591 // HTTPRequestHeaderFilter defines configuration for the RequestHeaderModifier 592 // filter. 593 type HTTPRequestHeaderFilter struct { 594 // Set overwrites the request with the given header (name, value) 595 // before the action. 596 // 597 // Input: 598 // GET /foo HTTP/1.1 599 // my-header: foo 600 // 601 // Config: 602 // set: 603 // - name: "my-header" 604 // value: "bar" 605 // 606 // Output: 607 // GET /foo HTTP/1.1 608 // my-header: bar 609 // 610 // +optional 611 // +listType=map 612 // +listMapKey=name 613 // +kubebuilder:validation:MaxItems=16 614 Set []HTTPHeader `json:"set,omitempty"` 615 616 // Add adds the given header(s) (name, value) to the request 617 // before the action. It appends to any existing values associated 618 // with the header name. 619 // 620 // Input: 621 // GET /foo HTTP/1.1 622 // my-header: foo 623 // 624 // Config: 625 // add: 626 // - name: "my-header" 627 // value: "bar" 628 // 629 // Output: 630 // GET /foo HTTP/1.1 631 // my-header: foo 632 // my-header: bar 633 // 634 // +optional 635 // +listType=map 636 // +listMapKey=name 637 // +kubebuilder:validation:MaxItems=16 638 Add []HTTPHeader `json:"add,omitempty"` 639 640 // Remove the given header(s) from the HTTP request before the action. The 641 // value of Remove is a list of HTTP header names. Note that the header 642 // names are case-insensitive (see 643 // https://datatracker.ietf.org/doc/html/rfc2616#section-4.2). 644 // 645 // Input: 646 // GET /foo HTTP/1.1 647 // my-header1: foo 648 // my-header2: bar 649 // my-header3: baz 650 // 651 // Config: 652 // remove: ["my-header1", "my-header3"] 653 // 654 // Output: 655 // GET /foo HTTP/1.1 656 // my-header2: bar 657 // 658 // +optional 659 // +kubebuilder:validation:MaxItems=16 660 Remove []string `json:"remove,omitempty"` 661 } 662 663 // HTTPPathModifierType defines the type of path redirect or rewrite. 664 type HTTPPathModifierType string 665 666 // HTTPPathModifier defines configuration for path modifiers. 667 // <gateway:experimental> 668 type HTTPPathModifier struct { 669 // Type defines the type of path modifier. Additional types may be 670 // added in a future release of the API. 671 // 672 // Note that values may be added to this enum, implementations 673 // must ensure that unknown values will not cause a crash. 674 // 675 // Unknown values here must result in the implementation setting the 676 // Attached Condition for the Route to `status: False`, with a 677 // Reason of `UnsupportedValue`. 678 // 679 // <gateway:experimental> 680 // +kubebuilder:validation:Enum=ReplaceFullPath;ReplacePrefixMatch 681 Type HTTPPathModifierType `json:"type"` 682 683 // ReplaceFullPath specifies the value with which to replace the full path 684 // of a request during a rewrite or redirect. 685 // 686 // <gateway:experimental> 687 // +kubebuilder:validation:MaxLength=1024 688 // +optional 689 ReplaceFullPath *string `json:"replaceFullPath,omitempty"` 690 691 // ReplacePrefixMatch specifies the value with which to replace the prefix 692 // match of a request during a rewrite or redirect. For example, a request 693 // to "/foo/bar" with a prefix match of "/foo" would be modified to "/bar". 694 // 695 // Note that this matches the behavior of the PathPrefix match type. This 696 // matches full path elements. A path element refers to the list of labels 697 // in the path split by the `/` separator. When specified, a trailing `/` is 698 // ignored. For example, the paths `/abc`, `/abc/`, and `/abc/def` would all 699 // match the prefix `/abc`, but the path `/abcd` would not. 700 // 701 // <gateway:experimental> 702 // +kubebuilder:validation:MaxLength=1024 703 // +optional 704 ReplacePrefixMatch *string `json:"replacePrefixMatch,omitempty"` 705 } 706 707 // HTTPRequestRedirect defines a filter that redirects a request. This filter 708 // MUST NOT be used on the same Route rule as a HTTPURLRewrite filter. 709 type HTTPRequestRedirectFilter struct { 710 // Scheme is the scheme to be used in the value of the `Location` 711 // header in the response. 712 // When empty, the scheme of the request is used. 713 // 714 // Support: Extended 715 // 716 // Note that values may be added to this enum, implementations 717 // must ensure that unknown values will not cause a crash. 718 // 719 // Unknown values here must result in the implementation setting the 720 // Attached Condition for the Route to `status: False`, with a 721 // Reason of `UnsupportedValue`. 722 // 723 // +optional 724 // +kubebuilder:validation:Enum=http;https 725 Scheme *string `json:"scheme,omitempty"` 726 727 // Hostname is the hostname to be used in the value of the `Location` 728 // header in the response. 729 // When empty, the hostname of the request is used. 730 // 731 // Support: Core 732 // 733 // +optional 734 Hostname *gatewayapiv1alpha2.PreciseHostname `json:"hostname,omitempty"` 735 736 // Path defines parameters used to modify the path of the incoming request. 737 // The modified path is then used to construct the `Location` header. When 738 // empty, the request path is used as-is. 739 // 740 // Support: Extended 741 // 742 // <gateway:experimental> 743 // +optional 744 Path *HTTPPathModifier `json:"path,omitempty"` 745 746 // Port is the port to be used in the value of the `Location` 747 // header in the response. 748 // When empty, port (if specified) of the request is used. 749 // 750 // Support: Extended 751 // 752 // +optional 753 Port *gatewayapiv1alpha2.PortNumber `json:"port,omitempty"` 754 755 // StatusCode is the HTTP status code to be used in response. 756 // 757 // Support: Core 758 // 759 // Note that values may be added to this enum, implementations 760 // must ensure that unknown values will not cause a crash. 761 // 762 // Unknown values here must result in the implementation setting the 763 // Attached Condition for the Route to `status: False`, with a 764 // Reason of `UnsupportedValue`. 765 // 766 // +optional 767 // +kubebuilder:default=302 768 // +kubebuilder:validation:Enum=301;302 769 StatusCode *int `json:"statusCode,omitempty"` 770 } 771 772 // HTTPRouteStatus defines the observed state of HTTPRoute. 773 type HTTPRouteStatus struct { 774 gatewayapiv1alpha2.RouteStatus `json:",inline"` 775 } 776