22
33import fr .sandro642 .github .ConnectLib ;
44import fr .sandro642 .github .spring .dto .Request ;
5- import fr .sandro642 .github .spring .dto .RouteInfo ;
65import org .springframework .web .bind .annotation .*;
76
87import java .util .*;
@@ -58,34 +57,47 @@ public static DataController getInstance() {
5857 @ GetMapping ("/status" )
5958 public Map <String , Object > getStatus () {
6059 Map <String , Object > status = new HashMap <>();
60+ status .put ("portInfo" , connectLib .StoreAndRetrieve ().get (connectLib .StoreAndRetrieve ().DYNAMIC_PORT ));
6161 status .put ("isInitialized" , connectLib .isInitialized ());
6262 status .put ("resourceType" , connectLib .HookManager ().getResourceType ());
6363 return status ;
6464 }
6565
66- /**
67- * Endpoint to get the available routes from ConnectLib.
68- * @return a list of RouteInfo objects representing the routes
69- */
7066 @ GetMapping ("/routes" )
71- public List < RouteInfo > getRoutes () {
67+ public Map < String , Object > getRoutes () {
7268 Map <String , String > map = connectLib .getRoutesMap ();
73- List <RouteInfo > result = new ArrayList <>();
69+ Map <String , Object > result = new HashMap <>();
70+
71+ // portInfo
72+ result .put ("portInfo" , connectLib .StoreAndRetrieve ().get (connectLib .StoreAndRetrieve ().DYNAMIC_PORT ).toString ());
73+
74+ List <Map <String , String >> routes = new ArrayList <>();
7475 if (map != null ) {
7576 for (Map .Entry <String , String > e : map .entrySet ()) {
76- result .add (new RouteInfo (e .getKey (), e .getValue ()));
77+ Map <String , String > route = new HashMap <>();
78+ route .put ("name" , e .getKey ());
79+ route .put ("url" , e .getValue ());
80+ routes .add (route );
7781 }
7882 }
83+ result .put ("routes" , routes );
7984 return result ;
8085 }
8186
87+
8288 /**
8389 * Endpoint to get all requests.
8490 * @return a list of Request objects
8591 */
8692 @ GetMapping ("/requests" )
87- public List <Request > getRequests () {
88- List <Request > result = new ArrayList <>(requestsMap .values ());
93+ public Map <String , Object > getRequests () {
94+ Map <String , Object > result = new HashMap <>();
95+
96+ result .put ("portInfo" , connectLib .StoreAndRetrieve ().get (connectLib .StoreAndRetrieve ().DYNAMIC_PORT ).toString ());
97+
98+ List <Request > requests = new ArrayList <>(requestsMap .values ());
99+ result .put ("requests" , requests );
100+
89101 return result ;
90102 }
91103
@@ -108,7 +120,7 @@ public Request createRequest(String route, String branch) {
108120 }
109121 long id = requestIdCounter .incrementAndGet ();
110122
111- Request req = new Request (id , route , branch , "pending" );
123+ Request req = new Request (connectLib . StoreAndRetrieve (). get ( connectLib . StoreAndRetrieve (). DYNAMIC_PORT ). toString (), id , route , branch , "pending" );
112124 requestsMap .put (id , req );
113125 return req ;
114126 }
0 commit comments