gateway_internal/method_binding.rs
1use crate::body_mapping::BodyMapping;
2use crate::path_template::PathTemplate;
3use crate::query_parameter::QueryParamFilter;
4
5/// Represents a binding of an HTTP method to a gRPC method.
6/// Corresponds to `Binding` in `grpc-gateway-golang`.
7#[derive(Debug, Clone, PartialEq)]
8pub struct MethodBinding {
9 /// The HTTP method (e.g., "GET", "POST").
10 pub http_method: String,
11
12 /// The compiled path template for this binding.
13 pub path_tmpl: PathTemplate,
14
15 /// The index of this binding in the `HttpRule.additional_bindings` list (or 0 if primary).
16 pub index: usize,
17
18 /// Path parameters extracted from the path template.
19 pub path_params: Vec<Parameter>,
20
21 /// Mapping for the request body.
22 pub body: Option<BodyMapping>,
23
24 /// Mapping for the response body.
25 pub response_body: Option<BodyMapping>,
26
27 /// Filter for query parameters.
28 pub query_param_filter: Option<QueryParamFilter>,
29}
30
31/// A path parameter extracted from the path template.
32#[derive(Debug, Clone, PartialEq)]
33pub struct Parameter {
34 /// The field path in the protobuf message.
35 pub field_path: String,
36
37 /// The type of the target field.
38 pub target_type: String, // e.g. "TYPE_STRING", "TYPE_INT32"
39
40 /// Whether the target field is repeated.
41 pub is_repeated: bool,
42
43 /// The protobuf field type (e.g. 12 for TYPE_BYTES).
44 pub field_type: Option<i32>,
45}