public class JsonHandler extends AbstractHandler<String>
Handler
that decodes JSON requests, sends them to a Service,
and encodes the responses into JSON.JsonServiceHandler.HandlerResponse<T>| Modifier and Type | Field and Description |
|---|---|
protected static com.fasterxml.jackson.databind.ObjectMapper |
MAPPER |
serviceHTTP_INTERNAL_SERVER_ERROR, HTTP_OK| Constructor and Description |
|---|
JsonHandler(Service service) |
| Modifier and Type | Method and Description |
|---|---|
Handler.HandlerResponse<String> |
apply(String jsonRequest)
Compute a response for the given request, handling errors generated by that computation.
|
(package private) Service.Request |
decode(String request) |
(package private) String |
encode(Service.Response response)
Serializes the provided object as JSON.
|
setRpcMetadata, unwrapExceptionpublic JsonHandler(Service service)
public Handler.HandlerResponse<String> apply(String jsonRequest)
AbstractHandlerapply in interface Handler<String>apply in class AbstractHandler<String>jsonRequest - The caller's request.Service.Response with additional context about that response.Service.Request decode(String request) throws IOException
decode in class AbstractHandler<String>IOExceptionString encode(Service.Response response) throws IOException
encode in class AbstractHandler<String>response - The object to serialize.IOExceptionCopyright © 2012–2016 The Apache Software Foundation. All rights reserved.