@@ -8,13 +8,12 @@ use uuid::Uuid;
88use crate :: client:: WebhookClient ;
99use crate :: config:: Config ;
1010use crate :: display:: {
11- print_full_request_body, print_request_body, print_request_details, print_request_headers,
12- print_request_summary,
11+ print_full_request_body, print_request_details, print_request_headers, print_request_summary,
1312} ;
1413
1514pub async fn generate_token ( config : & Config ) -> Result < ( ) > {
1615 let token = Uuid :: new_v4 ( ) ;
17- let webhook_url = format ! ( "{}/{}" , config. get_base_url( ) , token) ;
16+ let webhook_url = Config :: join_url_segments ( config. get_base_url ( ) , & [ & token. to_string ( ) ] ) ;
1817
1918 println ! ( "{}" , "New webhook token generated!" . bright_green( ) . bold( ) ) ;
2019 println ! ( ) ;
@@ -37,8 +36,10 @@ pub async fn generate_token(config: &Config) -> Result<()> {
3736 Ok ( ( ) )
3837}
3938
39+ #[ allow( clippy:: too_many_arguments) ]
4040pub async fn monitor_requests (
4141 client : & WebhookClient ,
42+ config : & Config ,
4243 token : & str ,
4344 initial_count : u32 ,
4445 interval : u64 ,
@@ -67,7 +68,7 @@ pub async fn monitor_requests(
6768 . into_iter ( )
6869 . filter ( |req| {
6970 method_filter. is_none_or ( |method| {
70- req. message_object . method . to_lowercase ( ) == method. to_lowercase ( )
71+ req. message_object . method . eq_ignore_ascii_case ( method)
7172 } )
7273 } )
7374 . collect ( ) ;
@@ -85,8 +86,13 @@ pub async fn monitor_requests(
8586 "Found" . bright_blue( ) ,
8687 filtered_requests. len( )
8788 ) ;
88- for request in & filtered_requests {
89- print_request_summary ( request) ;
89+ // Reverse the order so latest requests appear at the end
90+ for request in filtered_requests. iter ( ) . rev ( ) {
91+ print_request_summary (
92+ request,
93+ !full_body,
94+ config. get_body_preview_length ( ) ,
95+ ) ; // Don't show body preview in full body mode
9096 if show_headers {
9197 print_request_headers ( request) ;
9298 }
@@ -106,14 +112,16 @@ pub async fn monitor_requests(
106112 . collect ( ) ;
107113 for request in & new_requests {
108114 println ! ( "{}" , "NEW REQUEST" . bright_green( ) . bold( ) ) ;
109- print_request_summary ( request) ;
115+ print_request_summary (
116+ request,
117+ !full_body,
118+ config. get_body_preview_length ( ) ,
119+ ) ; // Don't show body preview in full body mode
110120 if show_headers {
111121 print_request_headers ( request) ;
112122 }
113123 if full_body {
114124 print_full_request_body ( request) ;
115- } else {
116- print_request_body ( request) ;
117125 }
118126 println ! ( "{}" , "─" . repeat( 80 ) . bright_black( ) ) ;
119127 last_seen_ids. insert ( request. id . clone ( ) ) ;
@@ -131,6 +139,7 @@ pub async fn monitor_requests(
131139
132140pub async fn show_logs (
133141 client : & WebhookClient ,
142+ config : & Config ,
134143 token : & str ,
135144 count : u32 ,
136145 method_filter : Option < & str > ,
@@ -150,9 +159,8 @@ pub async fn show_logs(
150159 let filtered_requests: Vec < _ > = requests
151160 . into_iter ( )
152161 . filter ( |req| {
153- method_filter. is_none_or ( |method| {
154- req. message_object . method . to_lowercase ( ) == method. to_lowercase ( )
155- } )
162+ method_filter
163+ . is_none_or ( |method| req. message_object . method . eq_ignore_ascii_case ( method) )
156164 } )
157165 . collect ( ) ;
158166
@@ -176,8 +184,9 @@ pub async fn show_logs(
176184 }
177185
178186 println ! ( "{}" , "─" . repeat( 80 ) . bright_black( ) ) ;
179- for request in & filtered_requests {
180- print_request_summary ( request) ;
187+ // Reverse the order so latest requests appear at the end
188+ for request in filtered_requests. iter ( ) . rev ( ) {
189+ print_request_summary ( request, !full_body, config. get_body_preview_length ( ) ) ; // Don't show body preview in full body mode
181190 if show_headers {
182191 print_request_headers ( request) ;
183192 }
0 commit comments