com.raynigon.ecs.logging.access.processor.BodyProcessor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ecs-logging-access Show documentation
Show all versions of ecs-logging-access Show documentation
The ecs-logging-access is a part of the unit-api
The newest version!
package com.raynigon.ecs.logging.access.processor;
import ch.qos.logback.access.common.spi.IAccessEvent;
import com.raynigon.ecs.logging.access.event.EcsAccessLogEvent;
import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor
public class BodyProcessor implements AccessEventProcessor {
private final int bodySizeLimit;
@Override
public EcsAccessLogEvent process(EcsAccessLogEvent result, IAccessEvent event) {
String requestBody = event.getRequestContent();
String responseBody = event.getResponseContent();
requestBody = limitSize(requestBody);
responseBody = limitSize(responseBody);
return result.toBuilder()
.requestBody(requestBody)
.responseBody(responseBody)
.build();
}
private String limitSize(String body) {
if (body == null || body.isEmpty()) return body;
if (body.length() <= bodySizeLimit) return body;
return body.substring(0, bodySizeLimit);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy