2121import java .util .Objects ;
2222
2323/**
24- * Allure interceptor logger for Retrofit .
24+ * Allure interceptor logger for OkHttp .
2525 */
2626public class AllureOkHttp3 implements Interceptor {
2727
28+ private String requestTemplatePath = "http-request.ftl" ;
29+ private String responseTemplatePath = "http-response.ftl" ;
30+
31+ public AllureOkHttp3 withRequestTemplate (final String templatePath ) {
32+ this .requestTemplatePath = templatePath ;
33+ return this ;
34+ }
35+
36+ public AllureOkHttp3 withResponseTemplate (final String templatePath ) {
37+ this .responseTemplatePath = templatePath ;
38+ return this ;
39+ }
2840
2941 @ Override
3042 public Response intercept (final Chain chain ) throws IOException {
@@ -40,7 +52,7 @@ public Response intercept(final Chain chain) throws IOException {
4052 requestAttachmentBuilder .withBody (readRequestBody (requestBody ));
4153 }
4254 final HttpRequestAttachment requestAttachment = requestAttachmentBuilder .build ();
43- processor .addAttachment (requestAttachment , new FreemarkerAttachmentRenderer ("http-request.ftl" ));
55+ processor .addAttachment (requestAttachment , new FreemarkerAttachmentRenderer (requestTemplatePath ));
4456
4557 final Response response = chain .proceed (request );
4658 final HttpResponseAttachment .Builder responseAttachmentBuilder = HttpResponseAttachment .Builder
@@ -57,7 +69,7 @@ public Response intercept(final Chain chain) throws IOException {
5769 }
5870
5971 final HttpResponseAttachment responseAttachment = responseAttachmentBuilder .build ();
60- processor .addAttachment (responseAttachment , new FreemarkerAttachmentRenderer ("http-response.ftl" ));
72+ processor .addAttachment (responseAttachment , new FreemarkerAttachmentRenderer (responseTemplatePath ));
6173
6274 return responseBuilder .build ();
6375 }
0 commit comments