Java 如何记录http请求&;标题和标题的响应;车身内部@AroundInvoke
我需要能够用头和体记录http请求和响应 目前,我有一个拦截器和一个Java 如何记录http请求&;标题和标题的响应;车身内部@AroundInvoke,java,quarkus,Java,Quarkus,我需要能够用头和体记录http请求和响应 目前,我有一个拦截器和一个@AroundInvoke建议记录主体。 但是,也有可能获得http头吗?在某种程度上 我在下面包含了一些代码片段 该项目正在使用Resteasy,即在pom中具有quarkus rest客户端依赖关系 //@LoggedClient not included in example @Priority(0) @Interceptor public class LoggingInterceptor { @Aro
@AroundInvoke
建议记录主体。
但是,也有可能获得http头吗?在某种程度上
我在下面包含了一些代码片段
该项目正在使用Resteasy,即在pom中具有quarkus rest客户端依赖关系
//@LoggedClient not included in example
@Priority(0)
@Interceptor
public class LoggingInterceptor {
@AroundInvoke
Object logInvocation(InvocationContext ctx) throws Exception {
logRequest(ctx);
try {
Object response = ctx.proceed();
logResponse(response);
return response;
} catch (WebApplicationException e) {
logError(e);
return e;
}
}
private void logError(WebApplicationException e) {/* impl */}
private void logResponse(Object response) {/* impl */}
private void logRequest(InvocationContext ctx) {/* impl which logs httpheader & body(class,method & request) */}
}
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
@Path("/offer")
//@LoggedClient not included in example
public class MyResource {
@Inject
@RestClient
MyClient client;
@POST
@Produces(APPLICATION_JSON)
public Response create(MyRequest req) {
MyResponse response = client.create(req);
return Response.ok().entity(response).build();
}
}
@Path("/somepath")
@RegisterRestClient
public interface MyClient {
@POST
@Produces(MediaType.APPLICATION_JSON)
@Path("/create")
MyResponse create(MyRequest req);
}
我们需要更多关于您正在使用的内容的详细信息:resteasy、反应式路由?例如,您可以添加
拦截器的一段代码来更好地理解上下文吗?