Class ContentPreviewingService
java.lang.Object
com.linecorp.armeria.common.util.AbstractUnwrappable<Service<T_I,T_O>>
com.linecorp.armeria.server.DecoratingService<I,O,I,O>
com.linecorp.armeria.server.SimpleDecoratingService<HttpRequest,HttpResponse>
com.linecorp.armeria.server.SimpleDecoratingHttpService
com.linecorp.armeria.server.logging.ContentPreviewingService
- All Implemented Interfaces:
Unwrappable
,HttpService
,Service<HttpRequest,HttpResponse>
public final class ContentPreviewingService extends SimpleDecoratingHttpService
Decorates an
HttpService
to preview the content of Request
s and Response
s.
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.
...
});
-
Method Summary
Modifier and Type Method Description static Function<? super HttpService,ContentPreviewingService>
newDecorator(int maxLength)
Creates a newContentPreviewingService
decorator which produces text preview with the specifiedmaxLength
limit.static Function<? super HttpService,ContentPreviewingService>
newDecorator(int maxLength, Charset defaultCharset)
Creates a newContentPreviewingService
decorator which produces text preview with the specifiedmaxLength
limit.static Function<? super HttpService,ContentPreviewingService>
newDecorator(ContentPreviewerFactory contentPreviewerFactory)
Creates a newContentPreviewingService
decorator with the specifiedContentPreviewerFactory
.HttpResponse
serve(ServiceRequestContext ctx, HttpRequest req)
Serves an incomingRequest
.Methods inherited from class com.linecorp.armeria.server.DecoratingService
serviceAdded, shouldCachePath
Methods inherited from class com.linecorp.armeria.common.util.AbstractUnwrappable
as, toString, unwrap
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.linecorp.armeria.server.Service
as, serviceAdded, shouldCachePath, unwrap
-
Method Details
-
newDecorator
Creates a newContentPreviewingService
decorator which produces text preview with the specifiedmaxLength
limit. The preview is produced when the content type of theRequestHeaders
orResponseHeaders
meets any of the following conditions:- when it matches
text/*
orapplication/x-www-form-urlencoded
- when its charset has been specified
- when its subtype is
"xml"
or"json"
- when its subtype ends with
"+xml"
or"+json"
- Parameters:
maxLength
- the maximum length of the preview
- when it matches
-
newDecorator
public static Function<? super HttpService,ContentPreviewingService> newDecorator(int maxLength, Charset defaultCharset)Creates a newContentPreviewingService
decorator which produces text preview with the specifiedmaxLength
limit. The preview is produced when the content type of theRequestHeaders
orResponseHeaders
meets any of the following conditions:- when it matches
text/*
orapplication/x-www-form-urlencoded
- when its charset has been specified
- when its subtype is
"xml"
or"json"
- when its subtype ends with
"+xml"
or"+json"
- Parameters:
maxLength
- the maximum length of the previewdefaultCharset
- the default charset used when a charset is not specified in the"content-type"
header
- when it matches
-
newDecorator
public static Function<? super HttpService,ContentPreviewingService> newDecorator(ContentPreviewerFactory contentPreviewerFactory)Creates a newContentPreviewingService
decorator with the specifiedContentPreviewerFactory
. -
serve
Description copied from interface:Service
Serves an incomingRequest
.
-