如何记录resteasy客户端请求

如何记录resteasy客户端请求

本文介绍了如何记录resteasy客户端请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在将其发送到客户端之前,我需要知道REST消息主体到底是什么,在处理之前,还需要知道它的响应,因此我尝试使用拦截器,但不幸的是,有效.

I need to know what is exactly the REST message body before sending it to client and also its response before processing, so I try to use Interceptors but unfortunately it is NOT working.

        @NameBinding
        public @interface DoIt {}

        @DoIt
        public class MyFilter implements ContainerRequestFilter {...}

        @Path("/root")
        public class MyResource {

           @GET
           @DoIt
           public String get() {...}
        }

由于服务器仅接受Https请求,因此我无法使用Wirehark捕获HTTP消息.

I can not use wireshark to capture http messages because my server only accept Https requests.

我在Resteasy中进行了很多搜索,发现了许多记录日志的方法,但是其中大多数是旧的且已过时,并且上述新方法不起作用.有人知道如何解决问题吗?

I searched a lot and find many ways to logging, in Resteasy but most of them are old and deprecated and the new way as above is not working.anyone know how to solve the problem?

RestEasy 3.0.9

RestEasy 3.0.9

JBoss EAP 6.3,其restEasy更新为3.0.9

JBoss EAP 6.3 with updated restEasy to 3.0.9

谢谢

我也测试了@Privider的ContainerRequestFilter.

I test @Privider for ContainerRequestFilter too.

也用于我的界面

@Target({ ElementType.TYPE, ElementType.METHOD })
@Retention(value = RetentionPolicy.RUNTIME)
@NameBinding

并将其添加到web.xml

and also add this to web.xml

<context-param>
    <param-name>resteasy.providers</param-name>
    <param-value>com.mypackage.RequestMessageLogger</param-value>
</context-param>

静态过滤器未调用.

推荐答案

您的ContainerRequestFilter缺少@Provider批注.来自 api -docs :

Your ContainerRequestFilter is missing the @Provider annotation. From the api-docs:

这应该有效:

@DoIt
@Provider
public class MyFilter implements ContainerRequestFilter {...}

这篇关于如何记录resteasy客户端请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-28 07:03