Class JsonService

java.lang.Object
io.helidon.webserver.JsonService
All Implemented Interfaces:
Handler, Service, BiConsumer<ServerRequest,ServerResponse>

public abstract class JsonService extends Object implements Service, Handler
A Service and abstract Handler that provides support for JSON content.
See Also:
  • Constructor Details

    • JsonService

      public JsonService()
  • Method Details

    • update

      public void update(Routing.Rules routingRules)
      Registers this handler for any HTTP method.
      Specified by:
      update in interface Service
      Parameters:
      routingRules - a routing configuration where JSON support should be registered
      See Also:
    • acceptsJson

      protected boolean acceptsJson(ServerRequest request, ServerResponse response)
      Determines if JSON is an accepted response type, using Accept and response Content-Type headers.

      Sets the response Content-Type header if not set and JSON is accepted.

      Parameters:
      request - a server request
      response - a server response
      Returns:
      true if JSON is accepted.
    • toJsonResponseType

      protected MediaType toJsonResponseType(MediaType acceptedType)
      Returns the response type for the given type if it is an accepted JSON type.
      Parameters:
      acceptedType - The accepted type.
      Returns:
      The response type or null if not an accepted JSON type.