@@ -74,76 +74,17 @@ impl ServiceType for ManagementEndpoint {
7474 async fn build_protocol_envelope (
7575 & self ,
7676 ctx : crate :: models:: protocol:: ProtocolCtx ,
77- _options : & HashMap < String , Value > ,
78- ) -> Result < RequestEnvelope < Vec < u8 > > , Error > {
79- use crate :: models:: envelope:: envelope:: RequestDetails ;
80- use std:: collections:: HashMap ;
81-
82- // Convert protocol context to request details
83- let mut headers = HashMap :: new ( ) ;
84- let mut cookies = HashMap :: new ( ) ;
85- let mut query_params = HashMap :: new ( ) ;
86- let metadata = ctx. meta ;
87-
88- // Extract data from attrs if it's an object
89- if let Some ( attrs_obj) = ctx. attrs . as_object ( ) {
90- // Extract headers
91- if let Some ( headers_val) = attrs_obj. get ( "headers" ) . and_then ( |v| v. as_object ( ) ) {
92- for ( k, v) in headers_val {
93- if let Some ( v_str) = v. as_str ( ) {
94- headers. insert ( k. clone ( ) , v_str. to_string ( ) ) ;
95- }
96- }
97- }
98-
99- // Extract cookies
100- if let Some ( cookies_val) = attrs_obj. get ( "cookies" ) . and_then ( |v| v. as_object ( ) ) {
101- for ( k, v) in cookies_val {
102- if let Some ( v_str) = v. as_str ( ) {
103- cookies. insert ( k. clone ( ) , v_str. to_string ( ) ) ;
104- }
105- }
106- }
107-
108- // Extract query params
109- if let Some ( query_val) = attrs_obj. get ( "query_params" ) . and_then ( |v| v. as_object ( ) ) {
110- for ( k, v) in query_val {
111- if let Some ( v_array) = v. as_array ( ) {
112- let strings: Vec < String > = v_array
113- . iter ( )
114- . filter_map ( |item| item. as_str ( ) . map ( |s| s. to_string ( ) ) )
115- . collect ( ) ;
116- query_params. insert ( k. clone ( ) , strings) ;
117- }
118- }
119- }
77+ options : & HashMap < String , Value > ,
78+ ) -> Result < crate :: models:: envelope:: envelope:: RequestEnvelope < Vec < u8 > > , crate :: utils:: Error >
79+ {
80+ // For HTTP protocol, delegate to HttpEndpoint for consistent HTTP parsing
81+ if ctx. protocol == crate :: models:: protocol:: Protocol :: Http {
82+ let http = crate :: models:: services:: types:: http:: HttpEndpoint { } ;
83+ return http. build_protocol_envelope ( ctx, options) . await ;
12084 }
121-
122- let request_details = RequestDetails {
123- method : ctx
124- . attrs
125- . get ( "method" )
126- . and_then ( |v| v. as_str ( ) )
127- . unwrap_or ( "GET" )
128- . to_string ( ) ,
129- uri : ctx
130- . attrs
131- . get ( "uri" )
132- . and_then ( |v| v. as_str ( ) )
133- . unwrap_or ( "/" )
134- . to_string ( ) ,
135- headers,
136- cookies,
137- query_params,
138- cache_status : ctx
139- . attrs
140- . get ( "cache_status" )
141- . and_then ( |v| v. as_str ( ) )
142- . map ( |s| s. to_string ( ) ) ,
143- metadata,
144- } ;
145-
146- Ok ( RequestEnvelope :: new ( request_details, ctx. payload ) )
85+ Err ( crate :: utils:: Error :: from (
86+ "JmixEndpoint only supports Protocol::Http envelope building" ,
87+ ) )
14788 }
14889}
14990
0 commit comments