Search in sources :

Example 1 with ZuulRuntimeException

use of org.springframework.cloud.netflix.zuul.util.ZuulRuntimeException in project spring-cloud-netflix by spring-cloud.

the class RibbonRoutingFilter method run.

@Override
public Object run() {
    RequestContext context = RequestContext.getCurrentContext();
    this.helper.addIgnoredHeaders();
    try {
        RibbonCommandContext commandContext = buildCommandContext(context);
        ClientHttpResponse response = forward(commandContext);
        setResponse(response);
        return response;
    } catch (ZuulException ex) {
        throw new ZuulRuntimeException(ex);
    } catch (Exception ex) {
        throw new ZuulRuntimeException(ex);
    }
}
Also used : RibbonCommandContext(org.springframework.cloud.netflix.ribbon.support.RibbonCommandContext) ZuulRuntimeException(org.springframework.cloud.netflix.zuul.util.ZuulRuntimeException) ZuulException(com.netflix.zuul.exception.ZuulException) RequestContext(com.netflix.zuul.context.RequestContext) ClientHttpResponse(org.springframework.http.client.ClientHttpResponse) HystrixRuntimeException(com.netflix.hystrix.exception.HystrixRuntimeException) ClientException(com.netflix.client.ClientException) ZuulRuntimeException(org.springframework.cloud.netflix.zuul.util.ZuulRuntimeException) IOException(java.io.IOException) ZuulException(com.netflix.zuul.exception.ZuulException)

Example 2 with ZuulRuntimeException

use of org.springframework.cloud.netflix.zuul.util.ZuulRuntimeException in project spring-cloud-netflix by spring-cloud.

the class SimpleHostRoutingFilter method run.

@Override
public Object run() {
    RequestContext context = RequestContext.getCurrentContext();
    HttpServletRequest request = context.getRequest();
    MultiValueMap<String, String> headers = this.helper.buildZuulRequestHeaders(request);
    MultiValueMap<String, String> params = this.helper.buildZuulRequestQueryParams(request);
    String verb = getVerb(request);
    InputStream requestEntity = getRequestBody(request);
    if (request.getContentLength() < 0) {
        context.setChunkedRequestBody();
    }
    String uri = this.helper.buildZuulRequestURI(request);
    this.helper.addIgnoredHeaders();
    try {
        CloseableHttpResponse response = forward(this.httpClient, verb, uri, request, headers, params, requestEntity);
        setResponse(response);
    } catch (Exception ex) {
        throw new ZuulRuntimeException(ex);
    }
    return null;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) InputStream(java.io.InputStream) ZuulRuntimeException(org.springframework.cloud.netflix.zuul.util.ZuulRuntimeException) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse) RequestContext(com.netflix.zuul.context.RequestContext) ZuulRuntimeException(org.springframework.cloud.netflix.zuul.util.ZuulRuntimeException) IOException(java.io.IOException)

Aggregations

RequestContext (com.netflix.zuul.context.RequestContext)2 IOException (java.io.IOException)2 ZuulRuntimeException (org.springframework.cloud.netflix.zuul.util.ZuulRuntimeException)2 ClientException (com.netflix.client.ClientException)1 HystrixRuntimeException (com.netflix.hystrix.exception.HystrixRuntimeException)1 ZuulException (com.netflix.zuul.exception.ZuulException)1 InputStream (java.io.InputStream)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)1 RibbonCommandContext (org.springframework.cloud.netflix.ribbon.support.RibbonCommandContext)1 ClientHttpResponse (org.springframework.http.client.ClientHttpResponse)1