use of com.predic8.membrane.core.rules.ServiceProxyKey in project service-proxy by membrane.
the class EmbeddingJava method main.
public static void main(String[] args) throws Exception {
String hostname = "*";
String method = "GET";
String path = ".*";
int listenPort = 4000;
ServiceProxyKey key = new ServiceProxyKey(hostname, method, path, listenPort);
String targetHost = "predic8.com";
int targetPort = 80;
ServiceProxy sp = new ServiceProxy(key, targetHost, targetPort);
sp.getInterceptors().add(new AddMyHeaderInterceptor());
HttpRouter router = new HttpRouter();
router.add(sp);
router.init();
}
use of com.predic8.membrane.core.rules.ServiceProxyKey in project service-proxy by membrane.
the class EtcdBasedConfigurator method setUpModuleServiceProxy.
private ServiceProxy setUpModuleServiceProxy(String name, int port, String path) {
log.info("Creating serviceProxy for module: " + path);
ServiceProxyKey key = new ServiceProxyKey("*", "*", path, port);
key.setUsePathPattern(true);
key.setPathRegExp(false);
ServiceProxy sp = new ServiceProxy(key, null, 0);
sp.getInterceptors().add(new LoadBalancingInterceptor());
try {
sp.init(router);
router.add(sp);
runningServiceProxyForModule.put(path, sp);
} catch (Exception ignored) {
}
return sp;
}
use of com.predic8.membrane.core.rules.ServiceProxyKey in project service-proxy by membrane.
the class ExceptionHandlingTest method setUp.
@Before
public void setUp() throws Exception {
router = new HttpRouter();
router.getTransport().setPrintStackTrace(printStackTrace);
ServiceProxy sp2 = new ServiceProxy(new ServiceProxyKey("*", "*", ".*", getPort()), "", -1);
sp2.getInterceptors().add(new AbstractInterceptor() {
@Override
public Outcome handleRequest(Exchange exc) throws Exception {
throw new Exception("secret");
}
});
router.getRuleManager().addProxyAndOpenPortIfNew(sp2);
router.init();
}
use of com.predic8.membrane.core.rules.ServiceProxyKey in project service-proxy by membrane.
the class BoundConnectionTest method setUp.
@Before
public void setUp() throws Exception {
router = new HttpRouter();
ServiceProxy sp1 = new ServiceProxy(new ServiceProxyKey("*", "*", ".*", 3021), "localhost", 3022);
router.getRuleManager().addProxyAndOpenPortIfNew(sp1);
ServiceProxy sp2 = new ServiceProxy(new ServiceProxyKey("*", "*", ".*", 3022), "", -1);
sp2.getInterceptors().add(new AbstractInterceptor() {
@Override
public Outcome handleRequest(Exchange exc) throws Exception {
exc.getRequest().readBody();
exc.setResponse(Response.ok("OK.").build());
connectionHash = ((HttpServerHandler) exc.getHandler()).getSrcOut().hashCode();
return Outcome.RETURN;
}
});
router.getRuleManager().addProxyAndOpenPortIfNew(sp2);
router.init();
}
use of com.predic8.membrane.core.rules.ServiceProxyKey in project service-proxy by membrane.
the class AccessControlInterceptorIntegrationTest method setUp.
@Before
public void setUp() throws Exception {
Rule rule = new ServiceProxy(new ServiceProxyKey("localhost", "POST", ".*", 3008), "thomas-bayer.com", 80);
router = new HttpRouter();
router.getRuleManager().addProxyAndOpenPortIfNew(rule);
}
Aggregations