use of io.fabric8.gateway.model.HttpProxyRule in project fabric8 by jboss-fuse.
the class JsonRuleBaseReaderTest method parseJson.
@Test
public void parseJson() throws Exception {
final InputStream in = JsonRuleBaseBuilder.newRuleBase().rule("/foo/{path}", "https://foo.com/cheese/{path}").rule("/cust/{id}/address/{addressId}", "http://at.com/addresses/{addressId}/cust/id}").inputStream();
Map<String, HttpProxyRule> rules = JsonRuleBaseReader.parseJson(in);
assertEquals("https://foo.com/cheese/{path}", asString(rules.get("/foo/{path}")));
assertEquals("http://at.com/addresses/{addressId}/cust/id}", asString(rules.get("/cust/{id}/address/{addressId}")));
assertClosed(in);
}
use of io.fabric8.gateway.model.HttpProxyRule in project fabric8 by jboss-fuse.
the class JsonRuleBaseReaderTest method parseWithGlobalDomainPath.
@Test
public void parseWithGlobalDomainPath() throws Exception {
final InputStream in = JsonRuleBaseBuilder.newRuleBase().globalCookieDomain(".global.com").rule("/foo/{path}", "https://foo.com/cheese/{path}").rule("/foo2/{path}", "https://foo2.com/cheese/{path}", null, "overriddenDomain").inputStream();
final Map<String, HttpProxyRule> rules = JsonRuleBaseReader.parseJson(in);
assertThat(rules.get("/foo/{path}").getCookieDomain(), equalTo(".global.com"));
assertThat(rules.get("/foo2/{path}").getCookieDomain(), equalTo("overriddenDomain"));
}
use of io.fabric8.gateway.model.HttpProxyRule in project fabric8 by jboss-fuse.
the class JsonRuleBaseReaderTest method parseWithCookiePathAndCookieDomain.
@Test
public void parseWithCookiePathAndCookieDomain() throws Exception {
final InputStream in = JsonRuleBaseBuilder.newRuleBase().rule("/foo/{path}", "https://foo.com/cheese/{path}", "/cookiePath", ".domain.com").inputStream();
final Map<String, HttpProxyRule> rules = JsonRuleBaseReader.parseJson(in);
final HttpProxyRule httpProxyRule = rules.get("/foo/{path}");
assertThat(httpProxyRule.getCookiePath(), equalTo("/cookiePath"));
assertThat(httpProxyRule.getCookieDomain(), equalTo(".domain.com"));
}
use of io.fabric8.gateway.model.HttpProxyRule in project fabric8 by jboss-fuse.
the class ProxyServlet method createProxyDetails.
protected ProxyDetails createProxyDetails(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) {
HttpMappingResult mappingRule = getResolver().findMappingRule(httpServletRequest, httpServletResponse);
final HttpProxyRule proxyRule = mappingRule.getProxyRule();
if (mappingRule != null) {
String destinationUrl = mappingRule.getDestinationUrl(new HttpClientRequestFacade(httpServletRequest, httpServletResponse));
if (destinationUrl != null) {
return new ProxyDetails(true, destinationUrl, proxyRule);
}
}
return new ProxyDetails(false, null, proxyRule);
}
Aggregations