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>
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 TypeMethodDescriptionbuilder
(ContentPreviewerFactory contentPreviewerFactory) Returns a newly-createdContentPreviewingServiceBuilder
.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
.serve
(ServiceRequestContext ctx, HttpRequest req) Serves an incomingRequest
.Methods inherited from class com.linecorp.armeria.server.SimpleDecoratingHttpService
exchangeType
Methods inherited from class com.linecorp.armeria.server.DecoratingService
serviceAdded, shouldCachePath
Methods inherited from class com.linecorp.armeria.common.util.AbstractUnwrappable
as, toString, unwrap, unwrapAll
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.HttpService
decorate, decorate
Methods inherited from interface com.linecorp.armeria.server.Service
as, serviceAdded, shouldCachePath, unwrap
Methods inherited from interface com.linecorp.armeria.common.util.Unwrappable
equalsIgnoreWrapper, unwrapAll
-
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
. -
builder
public static ContentPreviewingServiceBuilder builder(ContentPreviewerFactory contentPreviewerFactory) Returns a newly-createdContentPreviewingServiceBuilder
. -
serve
Description copied from interface:Service
Serves an incomingRequest
.
-