Search in sources :

Example 1 with ReverseProxyingInterceptor

use of com.predic8.membrane.core.interceptor.rewrite.ReverseProxyingInterceptor in project service-proxy by membrane.

the class Transport method init.

public void init(Router router) throws Exception {
    this.router = router;
    if (interceptors.isEmpty()) {
        interceptors.add(new RuleMatchingInterceptor());
        interceptors.add(new ExchangeStoreInterceptor(router.getExchangeStore()));
        interceptors.add(new DispatchingInterceptor());
        interceptors.add(new ReverseProxyingInterceptor());
        interceptors.add(new UserFeatureInterceptor());
        interceptors.add(new HTTPClientInterceptor());
    }
    for (Interceptor interceptor : interceptors) {
        interceptor.init(router);
    }
}
Also used : HTTPClientInterceptor(com.predic8.membrane.core.interceptor.HTTPClientInterceptor) ReverseProxyingInterceptor(com.predic8.membrane.core.interceptor.rewrite.ReverseProxyingInterceptor) ExchangeStoreInterceptor(com.predic8.membrane.core.interceptor.ExchangeStoreInterceptor) HTTPClientInterceptor(com.predic8.membrane.core.interceptor.HTTPClientInterceptor) DispatchingInterceptor(com.predic8.membrane.core.interceptor.DispatchingInterceptor) RuleMatchingInterceptor(com.predic8.membrane.core.interceptor.RuleMatchingInterceptor) Interceptor(com.predic8.membrane.core.interceptor.Interceptor) UserFeatureInterceptor(com.predic8.membrane.core.interceptor.UserFeatureInterceptor) ReverseProxyingInterceptor(com.predic8.membrane.core.interceptor.rewrite.ReverseProxyingInterceptor) ExchangeStoreInterceptor(com.predic8.membrane.core.interceptor.ExchangeStoreInterceptor) UserFeatureInterceptor(com.predic8.membrane.core.interceptor.UserFeatureInterceptor) RuleMatchingInterceptor(com.predic8.membrane.core.interceptor.RuleMatchingInterceptor) DispatchingInterceptor(com.predic8.membrane.core.interceptor.DispatchingInterceptor)

Example 2 with ReverseProxyingInterceptor

use of com.predic8.membrane.core.interceptor.rewrite.ReverseProxyingInterceptor in project service-proxy by membrane.

the class ReverseProxyingInterceptorTest method getRewrittenDestination.

/**
 * Lets the ReverseProxyingInterceptor handle a fake Exchange and returns the rewritten "Destination" header.
 */
private String getRewrittenDestination(String requestHostHeader, String requestDestinationHeader, int port, String requestURI, String targetScheme, int targetPort) throws Exception {
    Exchange exc = createExchange(requestHostHeader, requestDestinationHeader, port, requestURI, null);
    String url = new URL(targetScheme, "target", targetPort, exc.getRequest().getUri()).toString();
    exc.getDestinations().add(url);
    Assert.assertEquals(Outcome.CONTINUE, rp.handleRequest(exc));
    return exc.getRequest().getHeader().getFirstValue(Header.DESTINATION);
}
Also used : Exchange(com.predic8.membrane.core.exchange.Exchange) URL(java.net.URL)

Example 3 with ReverseProxyingInterceptor

use of com.predic8.membrane.core.interceptor.rewrite.ReverseProxyingInterceptor in project service-proxy by membrane.

the class ReverseProxyingInterceptorTest method getRewrittenRedirectionLocation.

/**
 * Lets the ReverseProxyingInterceptor handle a fake Exchange and returns the rewritten "Location" header.
 */
private String getRewrittenRedirectionLocation(String requestHostHeader, int port, String requestURI, String redirectionURI) throws Exception {
    Exchange exc = createExchange(requestHostHeader, null, port, requestURI, redirectionURI);
    Assert.assertEquals(Outcome.CONTINUE, rp.handleResponse(exc));
    return exc.getResponse().getHeader().getFirstValue(Header.LOCATION);
}
Also used : Exchange(com.predic8.membrane.core.exchange.Exchange)

Aggregations

Exchange (com.predic8.membrane.core.exchange.Exchange)2 DispatchingInterceptor (com.predic8.membrane.core.interceptor.DispatchingInterceptor)1 ExchangeStoreInterceptor (com.predic8.membrane.core.interceptor.ExchangeStoreInterceptor)1 HTTPClientInterceptor (com.predic8.membrane.core.interceptor.HTTPClientInterceptor)1 Interceptor (com.predic8.membrane.core.interceptor.Interceptor)1 RuleMatchingInterceptor (com.predic8.membrane.core.interceptor.RuleMatchingInterceptor)1 UserFeatureInterceptor (com.predic8.membrane.core.interceptor.UserFeatureInterceptor)1 ReverseProxyingInterceptor (com.predic8.membrane.core.interceptor.rewrite.ReverseProxyingInterceptor)1 URL (java.net.URL)1