File tree Expand file tree Collapse file tree 2 files changed +41
-1
lines changed
rust/templates/grpc-client Expand file tree Collapse file tree 2 files changed +41
-1
lines changed Original file line number Diff line number Diff line change 1414
1515package api
1616
17- import "slices"
17+ import (
18+ "slices"
19+ "strings"
20+ )
1821
1922// Typez represent different field types that may be found in messages.
2023type Typez int
@@ -344,6 +347,18 @@ type RoutingInfoVariant struct {
344347 Codec any
345348}
346349
350+ func (v * RoutingInfoVariant ) FieldName () string {
351+ return strings .Join (v .FieldPath , "." )
352+ }
353+
354+ func (v * RoutingInfoVariant ) TemplateAsString () string {
355+ var full []string
356+ full = append (full , v .Prefix .Segments ... )
357+ full = append (full , v .Matching .Segments ... )
358+ full = append (full , v .Suffix .Segments ... )
359+ return strings .Join (full , "/" )
360+ }
361+
347362type RoutingPathSpec struct {
348363 // A sequence of matching segments.
349364 //
Original file line number Diff line number Diff line change @@ -30,3 +30,28 @@ let x_goog_request_params = {
3030 { {/Routing} }
3131 ])
3232};
33+ { {#Codec.RoutingRequired} }
34+ if x_goog_request_params.is_empty() {
35+ use gax::error::binding::BindingError;
36+ use gaxi::routing_parameter::Segment;
37+ use gaxi::path_parameter::PathMismatchBuilder;
38+ let mut paths = Vec::new();
39+ {{#Routing} }
40+ { {#Variants} }
41+ {
42+ let builder = PathMismatchBuilder::default ().maybe_add(
43+ Some(&req){{#Codec.FieldAccessors} }{ {{.} }}{ {/Codec.FieldAccessors} },
44+ & [
45+ { {#Codec.PrefixSegments} }{ {{.} }}, { {/Codec.PrefixSegments} }
46+ { {#Codec.MatchingSegments} }{ {{.} }}, { {/Codec.MatchingSegments} }
47+ { {#Codec.SuffixSegments} }{ {{.} }}, { {/Codec.SuffixSegments} }
48+ ],
49+ "{ {FieldName} }",
50+ "{ {{TemplateAsString} }}");
51+ paths.push(builder.build());
52+ }
53+ { {/Variants} }
54+ { {/Routing} }
55+ return Err(gax::error::Error::binding(BindingError { paths } ))
56+ }
57+ { {/Codec.RoutingRequired} }
You can’t perform that action at this time.
0 commit comments