public final class ContentPreviewingService extends SimpleDecoratingHttpService
HttpService to preview the content of Requests and Responses.
Note that this decorator just sets RequestOnlyLog.requestContentPreview() and
RequestLog.responseContentPreview(). You can get the previews using RequestLogAccess.
RequestLogAccess logAccess = ctx.log();
logAccess.whenComplete().thenApply(log -> {
// Call log.requestContentPreview() and log.responseContentPreview() to use them.
...
});
| Modifier and Type | Method and Description |
|---|---|
static Function<? super HttpService,ContentPreviewingService> |
newDecorator(ContentPreviewerFactory contentPreviewerFactory)
Creates a new
ContentPreviewingService decorator with the specified
ContentPreviewerFactory. |
static Function<? super HttpService,ContentPreviewingService> |
newDecorator(int maxLength)
Creates a new
ContentPreviewingService decorator which produces text preview with the
specified maxLength limit. |
static Function<? super HttpService,ContentPreviewingService> |
newDecorator(int maxLength,
Charset defaultCharset)
Creates a new
ContentPreviewingService decorator which produces text preview with the
specified maxLength limit. |
HttpResponse |
serve(ServiceRequestContext ctx,
HttpRequest req)
Serves an incoming
Request. |
serviceAdded, shouldCachePathas, delegate, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitdecorate, decorateas, decorate, serviceAdded, shouldCachePathpublic static Function<? super HttpService,ContentPreviewingService> newDecorator(int maxLength)
ContentPreviewingService decorator which produces text preview with the
specified maxLength limit. The preview is produced when the content type of the
RequestHeaders or ResponseHeaders meets any of the following conditions:
text/* or application/x-www-form-urlencoded"xml" or "json""+xml" or "+json"maxLength - the maximum length of the previewpublic static Function<? super HttpService,ContentPreviewingService> newDecorator(int maxLength, Charset defaultCharset)
ContentPreviewingService decorator which produces text preview with the
specified maxLength limit. The preview is produced when the content type of the
RequestHeaders or ResponseHeaders meets any of the following conditions:
text/* or application/x-www-form-urlencoded"xml" or "json""+xml" or "+json"maxLength - the maximum length of the previewdefaultCharset - the default charset used when a charset is not specified in the
"content-type" headerpublic static Function<? super HttpService,ContentPreviewingService> newDecorator(ContentPreviewerFactory contentPreviewerFactory)
ContentPreviewingService decorator with the specified
ContentPreviewerFactory.public HttpResponse serve(ServiceRequestContext ctx, HttpRequest req) throws Exception
ServiceRequest.Copyright © 2020 LeanCloud. All rights reserved.