use of com.predic8.membrane.core.interceptor.HeaderFilterInterceptor.Rule in project service-proxy by membrane.
the class ServiceInvocationTest method createFirstRule.
private ServiceProxy createFirstRule() {
ServiceProxy rule = new ServiceProxy(new ServiceProxyKey("localhost", Request.METHOD_POST, "*", 3016), "thomas-bayer.com", 80);
rule.setTargetURL("service:log");
rule.getInterceptors().add(new MockInterceptor("process"));
return rule;
}
use of com.predic8.membrane.core.interceptor.HeaderFilterInterceptor.Rule in project service-proxy by membrane.
the class RewriteInterceptorIntegrationTest method setUp.
@Before
public void setUp() throws Exception {
interceptor = new RewriteInterceptor();
interceptor.getMappings().add(new Mapping("/blz-service\\?wsdl", "/axis2/services/BLZService?wsdl", null));
Rule rule = new ServiceProxy(new ServiceProxyKey("localhost", "POST", ".*", 3006), "thomas-bayer.com", 80);
rule.getInterceptors().add(interceptor);
router = new HttpRouter();
router.getRuleManager().addProxyAndOpenPortIfNew(rule);
}
use of com.predic8.membrane.core.interceptor.HeaderFilterInterceptor.Rule in project service-proxy by membrane.
the class REST2SOAPInterceptorIntegrationTest method setUp.
@Before
public void setUp() throws Exception {
Rule rule = new ServiceProxy(new ServiceProxyKey("localhost", "*", ".*", 3004), "www.thomas-bayer.com", 80);
router = new HttpRouter();
router.getRuleManager().addProxyAndOpenPortIfNew(rule);
REST2SOAPInterceptor rest2SoapInt = new REST2SOAPInterceptor();
rest2SoapInt.setMappings(getMappings());
rule.getInterceptors().add(rest2SoapInt);
router.init();
}
use of com.predic8.membrane.core.interceptor.HeaderFilterInterceptor.Rule in project service-proxy by membrane.
the class TestServiceInterceptor method init.
@Override
public void init(final Router router) throws Exception {
super.init(router);
wi.init(router);
Rule r = router.getParentProxy(this);
if (r instanceof AbstractServiceProxy) {
final Path path = ((AbstractServiceProxy) r).getPath();
if (path != null) {
if (path.isRegExp())
throw new Exception("<testService> may not be used together with <path isRegExp=\"true\">.");
final String keyPath = path.getValue();
final String name = URLUtil.getName(router.getUriFactory(), keyPath);
wi.setPathRewriter(new PathRewriter() {
@Override
public String rewrite(String path2) {
try {
if (path2.contains("://")) {
path2 = new URL(new URL(path2), keyPath).toString();
} else {
Matcher m = RELATIVE_PATH_PATTERN.matcher(path2);
path2 = m.replaceAll("./" + name + "?");
}
} catch (MalformedURLException e) {
}
return path2;
}
});
}
}
}
use of com.predic8.membrane.core.interceptor.HeaderFilterInterceptor.Rule in project service-proxy by membrane.
the class HeaderFilterInterceptor method handleMessage.
private void handleMessage(Message msg) {
if (msg == null)
return;
Header h = msg.getHeader();
if (h == null)
return;
for (HeaderField hf : h.getAllHeaderFields()) for (Rule r : rules) if (r.matches(hf.getHeaderName().toString())) {
switch(r.getAction()) {
case REMOVE:
log.debug("Removing HTTP header " + hf.getHeaderName().toString());
h.remove(hf);
break;
case KEEP:
break;
}
break;
}
}
Aggregations