@Override
    public HttpResponse serve(ServiceRequestContext ctx, HttpRequest req) throws Exception {
        final Boolean settingContentPreview = ctx.attr(SETTING_CONTENT_PREVIEW);
        if (Boolean.TRUE.equals(settingContentPreview)) {
            return unwrap().serve(ctx, req);
        }
        ctx.setAttr(SETTING_CONTENT_PREVIEW, true);
        if (!req.isEmpty()) {
            final ContentPreviewer requestContentPreviewer =
                    contentPreviewerFactory.requestContentPreviewer(ctx, req.headers());
            req = setUpRequestContentPreviewer(ctx, req, requestContentPreviewer, requestPreviewSanitizer);
        } else {
            // Set empty String.
            ctx.logBuilder().requestContentPreview("");
        }

        try {
            ctx.logBuilder().defer(RequestLogProperty.RESPONSE_CONTENT_PREVIEW);
            final HttpResponse res = unwrap().serve(ctx, req);
            return setUpResponseContentPreviewer(contentPreviewerFactory, ctx, res, responsePreviewSanitizer);
        } catch (Throwable t) {
            ctx.logBuilder().responseContentPreview(null);
            return HttpResponse.ofFailure(t);
        }
    }
Creates a new instance that decorates the specified {@link HttpService}.
core/src/main/java/com/linecorp/armeria/server/logging/ContentPreviewingService.java