Package io.muserver

Class ContextHandler

  • All Implemented Interfaces:
    MuHandler

    public class ContextHandler
    extends java.lang.Object
    implements MuHandler
    A handler that wraps a list of other handlers and serves them at a certain path prefix (or context).

    Use this when you want to serve multiple handlers with the same path prefix.

    • Constructor Detail

      • ContextHandler

        @Deprecated
        public ContextHandler​(java.lang.String contextPath,
                              java.util.List<MuHandler> muHandlers)
        Deprecated.
        Creates a new handler
        Parameters:
        contextPath - The patch
        muHandlers - The handlers
    • Method Detail

      • handle

        public boolean handle​(MuRequest request,
                              MuResponse response)
                       throws java.lang.Exception
        Description copied from interface: MuHandler
        Called when an HTTP request is made (unless a previous handler stopped handler processing)
        Specified by:
        handle in interface MuHandler
        Parameters:
        request - The HTTP request.
        response - The HTTP response.
        Returns:
        Return false to continue processing the next handler (for example if writing a filter or inspector); or true to stop processing (normally done if this handler sent a response).
        Throws:
        java.lang.Exception - Any uncaught exceptions will result in a 500 error code being returned to the client with a simple message.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object