Skip to content

Commit

Permalink
refactor: cleanup RoutesResource
Browse files Browse the repository at this point in the history
  • Loading branch information
NiccoMlt authored and dmercuriali committed Nov 28, 2024
1 parent 93b5b8a commit 8be93df
Showing 1 changed file with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
*/
package org.carapaceproxy.api;

import static org.carapaceproxy.server.mapper.StandardEndpointMapper.ACME_CHALLENGE_ROUTE_ACTION_ID;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.ServletContext;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import org.carapaceproxy.core.HttpProxyServer;
import static org.carapaceproxy.server.mapper.StandardEndpointMapper.ACME_CHALLENGE_ROUTE_ACTION_ID;

/**
* Access to configured routes
Expand Down Expand Up @@ -77,24 +77,25 @@ public String getMatcher() {
return matcher;
}

public String getMaintenanceAction() { return maintenanceAction; }
public String getMaintenanceAction() {
return maintenanceAction;
}
}

@GET
public List<RouteBean> getAll() {
final List<RouteBean> routes = new ArrayList();
final List<RouteBean> routes = new ArrayList<>();
HttpProxyServer server = (HttpProxyServer) context.getAttribute("server");
server.getMapper().getRoutes().stream()
.filter(r -> !r.getId().equals(ACME_CHALLENGE_ROUTE_ACTION_ID))
.forEach(route -> {
routes.add(new RouteBean(
route.getId(),
route.getAction(),
route.getErrorAction(),
route.isEnabled(),
route.getMatcher().getDescription(),
route.getMaintenanceModeAction()));
});
.forEach(route -> routes.add(new RouteBean(
route.getId(),
route.getAction(),
route.getErrorAction(),
route.isEnabled(),
route.getMatcher().getDescription(),
route.getMaintenanceModeAction()
)));

return routes;
}
Expand Down

0 comments on commit 8be93df

Please sign in to comment.