Class UrlRouter

    • Constructor Detail

      • UrlRouter

        public UrlRouter()
        Constructs a url router without default handler.
      • UrlRouter

        public UrlRouter​(Handler defaultHandler)
        Constructs a url router with default handler.
        Parameters:
        defaultHandler - default handler
    • Method Detail

      • register

        public final UrlRouter register​(Pattern urlPattern,
                                        Handler handler)
        Adds a url pattern, and the handler to be used.

        Please note that the pattern must be an exact match of the url to work.

        Parameters:
        urlPattern - regex pattern of the url.
        handler - handler to which the fetched page should use.
        Returns:
        this.
      • register

        public final UrlRouter register​(Pattern urlPattern,
                                        Validator validator)
        Adds a url pattern, and the handler to be used.

        Please note that the pattern must be an exact match of the url to work.

        Parameters:
        urlPattern - regex pattern of the url.
        validator - validator to which the fetched page should use.
        Returns:
        this.
      • register

        public final UrlRouter register​(Pattern urlPattern,
                                        Handler handler,
                                        Validator validator)
        Adds a url pattern, and the handler to be used.

        Please note that the pattern must be an exact match of the url to work.

        Parameters:
        urlPattern - regex pattern of the url.
        handler - handler to which the fetched page should use.
        validator - validator to which the fetched page should use.
        Returns:
        this.
      • getHandler

        public final Handler getHandler​(Request request)
        Description copied from interface: HandlerRouter
        Returns the handler to be used for a specified request.

        This will only be used if a handler is not specified in when added to scheduler.

        Specified by:
        getHandler in interface HandlerRouter
        Parameters:
        request - request made
        Returns:
        the instance of handler to be used
      • getValidator

        public final Validator getValidator​(Request request)
        Description copied from interface: ValidatorRouter
        Returns the handler to be used for a specified request.

        This will only be used if a handler is not specified in when added to scheduler

        Specified by:
        getValidator in interface ValidatorRouter
        Parameters:
        request - request made
        Returns:
        the instance of handler to be used