2 Replies Latest reply on Feb 15, 2014 2:23 AM by yagerhard

    Errai and RestClientInterceptor

    yagerhard

      Dear all,

       

      I've implemented a RestClientInteceptor and all is well for the request side of things.

      However, I'm having some problems with the response side.

       

      I have a line in the code:   context.proceed(callback);

      The problem is that I have no idea how to access the Response Headers from my callback. The callback gets called and everything is OK - I just can't seem to find out how to access the info I need.

      Any examples of a callback accessing response headers would be great.

       

      Any help is most appreciated.

       

      Cheers,

       

      MarkB

        • 1. Re: Errai and RestClientInterceptor
          csa

          Hi Mark,

           

          Using either 2.4.4-SNAPSHOT or 3.0-SNAPSHOT you should be able to pass a ResponseCallback to your context.proceed call even if your actual remote callback is a standard RemoteCallback. The ResponseCallback provides access to the Response object and its headers.

           

            @Override
            public void aroundInvoke(final RestCallContext context) {
              context.proceed(new ResponseCallback() {
                @Override
                  public void callback(Response response) {
                   // access headers using response.getHeaders()..
                    context.setResult(...);
                  }
                });
              }
          

           

          Don't forget to set the result using context.setResult.

           

          Cheers,

          Christian

          • 2. Re: Re: Errai and RestClientInterceptor
            yagerhard

            Hi Christian,

             

            Sounds like that's exactly what I need.

            I'd like to move up to either of the two snapshots that you've provided, but I always seem to have a lot of difficulty amending my pom.xml to make the jump to the new version. There always seems to be something that doesn't work and prevents me from continuing.

            Here's my existing pom (attached) - what should I change to move to either 2.4.4 snapshot or 3.0-snapshot?

            Many thanks,

             

            MarkB