public class JsonHandler extends AbstractHandler<String>
Handler
that decodes JSON requests, sends them to a Service
,
and encodes the responses into JSON.JsonService
Handler.HandlerResponse<T>
Modifier and Type | Field and Description |
---|---|
protected static com.fasterxml.jackson.databind.ObjectMapper |
MAPPER |
service
HANDLER_SERIALIZATION_METRICS_NAME, HTTP_INTERNAL_SERVER_ERROR, HTTP_OK, HTTP_UNAUTHENTICATED, HTTP_UNAUTHORIZED
Constructor and Description |
---|
JsonHandler(Service service,
MetricsSystem metrics) |
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.
|
convertToErrorResponse, setRpcMetadata, unauthenticatedErrorResponse, unauthorizedErrorResponse
public JsonHandler(Service service, MetricsSystem metrics)
public Handler.HandlerResponse<String> apply(String jsonRequest)
AbstractHandler
apply
in interface Handler<String>
apply
in class AbstractHandler<String>
jsonRequest
- The caller's request.Service.Response
with additional context about that response.Copyright © 2012–2018 The Apache Software Foundation. All rights reserved.