Class Handlers


  • public final class Handlers
    extends Object
    Utility methods for creating common types of handlers.
    • Method Detail

      • filtered

        public static DescribableHandler filtered​(Handler handler,
                                                  Filter filter)
        Creates a "filtered handler" instance.

        It will invoke the first filter, giving it the handler handler as next.

        Parameters:
        handler - The filtered instance
        filter - the filter to apply
        Returns:
        a new Handler instance that filters the given handler.
      • chainOf

        public static DescribableHandler chainOf​(Handler handler,
                                                 Filter... filters)
        Creates a Handler which wraps the provided filters around the provided target handler.
        Parameters:
        handler - The target handler which will be invoked once processing has reached the end of the filter chain.
        filters - The list of filters to be processed before invoking the target.
        Returns:
        A Handler.
        See Also:
        chainOf(Handler, List)
      • chainOf

        public static DescribableHandler chainOf​(Handler handler,
                                                 List<Filter> filters)
        Creates a Handler which wraps the provided filters around the provided target handler.
        Parameters:
        handler - The target handler which will be invoked once processing has reached the end of the filter chain.
        filters - The list of filters to be processed before invoking the target.
        Returns:
        A Handler.
        See Also:
        chainOf(Handler, Filter...)
      • asDescribableHandler

        public static DescribableHandler asDescribableHandler​(Handler handler)
        Adapts a Handler to a DescribableHandler without adding support for API Descriptions if it is not already implemented.
        Parameters:
        handler - The handler.
        Returns:
        The describable handler.
      • internalServerErrorHandler

        public static Handler internalServerErrorHandler​(Exception cause)
        A common HTTP Framework Handler responding 500 Internal Server Error.
        Parameters:
        cause - The cause of the internal server error.
        Returns:
        The handler.
      • forbiddenHandler

        public static Handler forbiddenHandler()
        A common HTTP Framework Handler responding 403 Forbidden.
        Returns:
        The handler.