use of com.predic8.membrane.core.HttpRouter in project service-proxy by membrane.
the class IllegalCharactersInURLTest method init.
@Before
public void init() throws Exception {
r = new HttpRouter();
r.setHotDeploy(false);
r.add(new ServiceProxy(new ServiceProxyKey(3027), "localhost", 3028));
ServiceProxy sp2 = new ServiceProxy(new ServiceProxyKey(3028), null, 80);
sp2.getInterceptors().add(new AbstractInterceptor() {
@Override
public Outcome handleRequest(Exchange exc) throws Exception {
Assert.assertEquals("/foo{}", exc.getRequestURI());
exc.setResponse(Response.ok().build());
return Outcome.RETURN;
}
});
r.add(sp2);
r.start();
}
use of com.predic8.membrane.core.HttpRouter 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.HttpRouter 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.HttpRouter 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.HttpRouter 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