@@ -488,13 +488,13 @@ pub enum HttpPathModifier {
488
488
/// ReplaceFullPath specifies the value with which to replace the full path
489
489
/// of a request during a rewrite or redirect.
490
490
#[ serde( rename_all = "camelCase" ) ]
491
- ReplaceFullPath ( String ) ,
491
+ ReplaceFullPath { replace_full_path : String } ,
492
492
493
493
/// ReplacePrefixMatch specifies the value with which to replace the prefix
494
494
/// match of a request during a rewrite or redirect. For example, a request
495
495
/// to "/foo/bar" with a prefix match of "/foo" would be modified to "/bar".
496
496
#[ serde( rename_all = "camelCase" ) ]
497
- ReplacePrefixMatch ( String ) ,
497
+ ReplacePrefixMatch { replace_prefix_match : String } ,
498
498
}
499
499
500
500
/// HTTPRequestRedirect defines a filter that redirects a request. This filter
@@ -629,3 +629,36 @@ pub struct HttpRouteStatus {
629
629
#[ serde( flatten) ]
630
630
pub inner : RouteStatus ,
631
631
}
632
+
633
+ #[ cfg( test) ]
634
+ mod test {
635
+ use super :: * ;
636
+
637
+ #[ test]
638
+ fn test_deserialize_http_route ( ) {
639
+ // Test json with a URLRewrote
640
+ let test_json = r#"{
641
+ "apiVersion":"gateway.networking.k8s.io/v1beta1",
642
+ "kind":"HTTPRoute",
643
+ "metadata":{"name":"route_name"},
644
+ "spec":{
645
+ "parentRefs":null,
646
+ "hostnames":null,
647
+ "rules":[{
648
+ "matches":null,
649
+ "filters":[{
650
+ "type":"URLRewrite",
651
+ "urlRewrite":{
652
+ "hostname":null,
653
+ "path":{
654
+ "type":"ReplacePrefixMatch",
655
+ "replacePrefixMatch":"/"
656
+ }
657
+ }
658
+ }],
659
+ "backendRefs":null
660
+ }]}}"# ;
661
+ let route: Result < HttpRoute , _ > = serde_json:: from_str ( test_json) ;
662
+ assert ! ( route. is_ok( ) ) ;
663
+ }
664
+ }
0 commit comments