public final class Middlewares extends Object
Middleware
implementations.Modifier and Type | Method and Description |
---|---|
static Middleware<AsyncHandler<?>,AsyncHandler<Response<okio.ByteString>>> |
apolloDefaults()
Returns the default middlewares applied by Apollo to routes supplied by a
RouteProvider . |
static <T> AsyncHandler<Response<okio.ByteString>> |
autoSerialize(AsyncHandler<T> inner)
Converts an AsyncHandler with unspecified return type to one that returns
Response<ByteString> . |
static AsyncHandler<Response<okio.ByteString>> |
httpPayloadSemantics(AsyncHandler<Response<okio.ByteString>> inner)
Applies logic to the inner
AsyncHandler that makes it conform to the semantics
specified in HTTP regarding when to return response bodies, Content-Length headers, etc. |
static Middleware<AsyncHandler<?>,AsyncHandler<Response<?>>> |
replyContentType(String contentType)
Middleware that adds the ability to set the response's Content-Type header to a defined
value.
|
static Middleware<AsyncHandler<?>,AsyncHandler<Response<okio.ByteString>>> |
serialize(Serializer serializer)
Middleware that applies the supplied serializer to the result of the inner handler,
changing the payload and optionally the Content-Type header.
|
public static <T> AsyncHandler<Response<okio.ByteString>> autoSerialize(AsyncHandler<T> inner)
Response<ByteString>
. This is done through a best-effort mechanism.
Using this middleware has the effect that your code is no longer typesafe, so it may be
preferable to write your own middleware that converts the domain object your handler returns
into a Response<ByteString>
.public static AsyncHandler<Response<okio.ByteString>> httpPayloadSemantics(AsyncHandler<Response<okio.ByteString>> inner)
AsyncHandler
that makes it conform to the semantics
specified in HTTP regarding when to return response bodies, Content-Length headers, etc.public static Middleware<AsyncHandler<?>,AsyncHandler<Response<?>>> replyContentType(String contentType)
public static Middleware<AsyncHandler<?>,AsyncHandler<Response<okio.ByteString>>> serialize(Serializer serializer)
public static Middleware<AsyncHandler<?>,AsyncHandler<Response<okio.ByteString>>> apolloDefaults()
RouteProvider
.Copyright © 2016. All rights reserved.