Class JsonService

    • Constructor Detail

      • JsonService

        public JsonService()
    • Method Detail

      • 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:
        Routing
      • 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.