@@ -146,6 +146,13 @@ fn issue_trace(ctx: &mut RequestContext) -> BoxFuture<'_, ()> {
146146 } ) . boxed ( )
147147}
148148
149+
150+ #[ derive( Serialize , Deserialize , Debug ) ]
151+ pub struct TreeStructure {
152+ tree : String ,
153+ }
154+
155+
149156// tree_structure handler
150157fn tree_structure ( ctx : & mut RequestContext ) -> BoxFuture < ' _ , ( ) > {
151158 let parsed: std:: collections:: HashMap < String , String > = serde_urlencoded:: from_str ( ctx. req . uri ( ) . query ( ) . unwrap ( ) ) . unwrap ( ) ;
@@ -155,8 +162,10 @@ fn tree_structure(ctx: &mut RequestContext) -> BoxFuture<'_, ()> {
155162 let suffix = "go" ;
156163 let mut body = String :: from ( "generate tree failed." ) ;
157164 let repo = PathBuf :: from ( format ! ( "./tmp/{}" , repo) ) ;
165+ let mut tree_struct = TreeStructure { tree : "" . to_string ( ) } ;
158166 if let Some ( tree) = files:: tree ( & repo, suffix) {
159- body = tree. to_string ( )
167+ tree_struct. tree = tree. to_string ( ) ;
168+ body = serde_json:: to_string_pretty ( & tree_struct) . unwrap ( ) ;
160169 }
161170 * ctx. resp . body_mut ( ) = Body :: from ( body) ;
162171 } ) . boxed ( )
@@ -168,10 +177,9 @@ async fn main() {
168177 let h = Hertz :: new ( ) ;
169178 h. get ( "/basic_info" , Arc :: new ( basic_info) ) . await ;
170179 h. get ( "/repo_stats" , Arc :: new ( repo_stats) ) . await ;
171- h. get ( "/issue_trace" , Arc :: new ( issue_trace) ) . await ;
172180
181+ h. get ( "/issue_trace" , Arc :: new ( issue_trace) ) . await ;
173182 h. get ( "/repo_structure" , Arc :: new ( tree_structure) ) . await ;
174-
175183 h. get ( "/code_analyze" , Arc :: new ( code_analyze) ) . await ;
176184
177185
0 commit comments