@@ -2272,13 +2272,42 @@ static bool is_route_path_shaped(const char *val) {
22722272 return val && val [0 ] == '/' && !cbm_service_pattern_is_comment_text (val );
22732273}
22742274
2275- static const char * find_route_path_in_args (const CBMCall * call , const char * * out_handler ) {
2275+ const char * cbm_pipeline_mux_route_path (const CBMCall * call , CBMLanguage lang ) {
2276+ const char * arg = call -> first_string_arg ;
2277+ if (lang != CBM_LANG_GO || !arg || cbm_service_pattern_is_comment_text (arg )) {
2278+ return NULL ;
2279+ }
2280+ return cbm_service_pattern_mux_route_path (call -> callee_name , arg );
2281+ }
2282+
2283+ const char * cbm_pipeline_route_reg_method (const CBMCall * call , CBMLanguage lang , char * buf ,
2284+ size_t buf_sz ) {
2285+ const char * method = cbm_service_pattern_route_method (call -> callee_name );
2286+ if (method && strcmp (method , "ANY" ) != 0 ) {
2287+ return method ;
2288+ }
2289+ if (cbm_pipeline_mux_route_path (call , lang ) &&
2290+ cbm_service_pattern_mux_split (call -> first_string_arg , buf , buf_sz ) && buf [0 ] != '\0' ) {
2291+ return buf ;
2292+ }
2293+ return method ;
2294+ }
2295+
2296+ static const char * find_route_path_in_args (const CBMCall * call , const char * * out_handler ,
2297+ CBMLanguage lang ) {
22762298 * out_handler = NULL ;
22772299 /* 1. First string arg starting with / */
22782300 if (is_route_path_shaped (call -> first_string_arg )) {
22792301 * out_handler = call -> second_arg_name ;
22802302 return call -> first_string_arg ;
22812303 }
2304+ /* 1b. Go ServeMux pattern with a method or host before the path (#2537),
2305+ * read for Handle / HandleFunc only. MUST match pass_calls.c route_reg_path. */
2306+ const char * mux_path = cbm_pipeline_mux_route_path (call , lang );
2307+ if (mux_path ) {
2308+ * out_handler = call -> second_arg_name ;
2309+ return mux_path ;
2310+ }
22822311 /* 2. Keyword args (prefix=, path=, route=, etc.) */
22832312 const char * found = NULL ;
22842313 for (int ai = 0 ; ai < call -> arg_count && !found ; ai ++ ) {
@@ -2438,7 +2467,8 @@ static bool emit_route_registration(cbm_gbuf_t *gbuf, const cbm_gbuf_node_t *sou
24382467 const cbm_registry_t * registry , const cbm_gbuf_t * main_gbuf ,
24392468 const char * * ik , const char * * iv , int ic ,
24402469 const char * route_mount , CBMLanguage lang ) {
2441- const char * method = cbm_service_pattern_route_method (call -> callee_name );
2470+ char mux_method [CBM_SZ_16 ];
2471+ const char * method = cbm_pipeline_route_reg_method (call , lang , mux_method , sizeof (mux_method ));
24422472 char mounted [CBM_SZ_256 ];
24432473 route_path = cbm_laravel_mount_route (route_mount , route_path , mounted , sizeof (mounted ));
24442474 char rqn [CBM_ROUTE_QN_SIZE ];
@@ -2824,7 +2854,7 @@ static bool emit_service_edge(cbm_gbuf_t *gbuf, const cbm_gbuf_node_t *source,
28242854
28252855 if (svc == CBM_SVC_ROUTE_REG ) {
28262856 const char * handler_ref = NULL ;
2827- const char * route_path = find_route_path_in_args (call , & handler_ref );
2857+ const char * route_path = find_route_path_in_args (call , & handler_ref , lang );
28282858 if (route_path ) {
28292859 return emit_route_registration (gbuf , source , call , route_path , handler_ref , module_qn ,
28302860 registry , main_gbuf , imp_keys , imp_vals , imp_count ,
@@ -2888,7 +2918,7 @@ static bool emit_xlang_refused_route(cbm_gbuf_t *gbuf, const cbm_gbuf_node_t *so
28882918 return false;
28892919 }
28902920 const char * handler_ref = NULL ;
2891- const char * route_path = find_route_path_in_args (call , & handler_ref );
2921+ const char * route_path = find_route_path_in_args (call , & handler_ref , lang );
28922922 if (route_path ) {
28932923 return emit_route_registration (gbuf , source , call , route_path , handler_ref , module_qn ,
28942924 registry , main_gbuf , imp_keys , imp_vals , imp_count ,
0 commit comments