use of com.predic8.membrane.core.interceptor.rest.REST2SOAPInterceptor.Mapping in project service-proxy by membrane.
the class DynamicAdminPageInterceptor method handleNodeShowRequest.
@Mapping("/admin/node/show/?(\\?.*)?")
public Response handleNodeShowRequest(final Map<String, String> params, String relativeRootPath) throws Exception {
StringWriter writer = new StringWriter();
return respond(new AdminPageBuilder(writer, router, relativeRootPath, params, readOnly) {
@Override
protected int getSelectedTab() {
return TAB_ID_LOAD_BALANCING;
}
@Override
protected void createTabContent() throws Exception {
String balancer = getBalancerParam(params);
h2().text("Node " + params.get("host") + ":" + params.get("port") + " (" + "Cluster " + params.get("cluster") + " of Balancer " + balancer + ")").end();
h3().text("Status Codes").end();
Node n = BalancerUtil.lookupBalancer(router, balancer).getNode(params.get("cluster"), params.get("host"), Integer.parseInt(params.get("port")));
createStatusCodesTable(n.getStatisticsByStatusCodes());
p().text("Total requests: " + n.getCounter()).end();
p().text("Current threads: " + n.getThreads()).end();
p().text("Requests without responses: " + n.getLost()).end();
span().classAttr("mb-button");
createLink("Reset Counter", "node", "reset", createQueryString("balancer", balancer, "cluster", params.get("cluster"), "host", n.getHost(), "port", "" + n.getPort()));
end();
span().classAttr("mb-button");
createLink("Show Sessions", "node", "sessions", createQueryString("balancer", balancer, "cluster", params.get("cluster"), "host", n.getHost(), "port", "" + n.getPort()));
end();
}
}.createPage());
}
use of com.predic8.membrane.core.interceptor.rest.REST2SOAPInterceptor.Mapping in project service-proxy by membrane.
the class DynamicAdminPageInterceptor method handleServiceProxyStartRequest.
@Mapping("/admin/service-proxy/start/?(\\?.*)?")
public Response handleServiceProxyStartRequest(Map<String, String> params, String relativeRootPath) throws Exception {
if (readOnly)
return createReadOnlyErrorResponse();
Rule rule = RuleUtil.findRuleByIdentifier(router, params.get("name"));
Rule newRule = rule.clone();
router.getRuleManager().replaceRule(rule, newRule);
return respond(getServiceProxyPage(params, relativeRootPath));
}
use of com.predic8.membrane.core.interceptor.rest.REST2SOAPInterceptor.Mapping in project service-proxy by membrane.
the class DynamicAdminPageInterceptor method handlePruleShowRequest.
@Mapping("/admin/proxy/show/?(\\?.*)?")
public Response handlePruleShowRequest(final Map<String, String> params, String relativeRootPath) throws Exception {
StringWriter writer = new StringWriter();
final ProxyRule rule = (ProxyRule) RuleUtil.findRuleByIdentifier(router, params.get("name"));
return respond(new AdminPageBuilder(writer, router, relativeRootPath, params, readOnly) {
@Override
protected int getSelectedTab() {
return TAB_ID_PROXIES;
}
@Override
protected String getTitle() {
return super.getTitle() + " " + rule.toString() + " Proxy";
}
@Override
protected void createTabContent() throws Exception {
h1().text(rule.toString() + " Proxy").end();
if (rule.getKey().getPort() != -1) {
table();
createTr("Listen Port", "" + rule.getKey().getPort());
end();
}
h2().text("Status Codes").end();
createStatusCodesTable(rule.getStatisticsByStatusCodes());
h2().text("Interceptors").end();
createInterceptorTable(rule.getInterceptors());
}
}.createPage());
}
use of com.predic8.membrane.core.interceptor.rest.REST2SOAPInterceptor.Mapping in project service-proxy by membrane.
the class DynamicAdminPageInterceptor method handleServiceProxySaveRequest.
@Mapping("/admin/service-proxy/save/?(\\?.*)?")
public Response handleServiceProxySaveRequest(Map<String, String> params, String relativeRootPath) throws Exception {
if (readOnly)
return createReadOnlyErrorResponse();
logAddFwdRuleParams(params);
Rule r = new ServiceProxy(new ServiceProxyKey("*", params.get("method"), ".*", getPortParam(params), null), params.get("targetHost"), getTargetPortParam(params));
r.setName(params.get("name"));
try {
router.getRuleManager().addProxyAndOpenPortIfNew(r);
} catch (PortOccupiedException e) {
return Response.internalServerError("The port could not be opened: Either it is occupied or Membrane does " + "not have enough privileges to do so.").build();
}
return respond(getServiceProxyPage(params, relativeRootPath));
}
Aggregations