Package ninja

Class Route

  • public class Route
    extends Object
    A route
    • Method Detail

      • getUrl

        public String getUrl()
        Use getUri()
      • getHttpMethod

        public String getHttpMethod()
      • isHttpMethod

        public boolean isHttpMethod​(String method)
      • isHttpMethodGet

        public boolean isHttpMethodGet()
      • isHttpMethodPost

        public boolean isHttpMethodPost()
      • isHttpMethodPut

        public boolean isHttpMethodPut()
      • isHttpMethodDelete

        public boolean isHttpMethodDelete()
      • isHttpMethodHead

        public boolean isHttpMethodHead()
      • isHttpMethodOptions

        public boolean isHttpMethodOptions()
      • isHttpMethodWebSocket

        public boolean isHttpMethodWebSocket()
      • getUri

        public String getUri()
      • getControllerClass

        public Class<?> getControllerClass()
      • getControllerMethod

        public Method getControllerMethod()
      • matches

        public boolean matches​(String httpMethod,
                               String uri)
        Matches /index to /index or /me/1 to /person/{id}
        True if the actual route matches a raw rout. False if not.
      • getPathParametersEncoded

        public Map<String,​String> getPathParametersEncoded​(String uri)
        This method does not do any decoding / encoding. If you want to decode you have to do it yourself. Most likely with:
        uri - The whole encoded uri.
        A map with all parameters of that uri. Encoded in => encoded out.
      • convertRawUriToRegex

        protected static String convertRawUriToRegex​(String rawUri)
        Gets a raw uri like "/{name}/id/*" and returns "/([^/]*)/id/*." Also handles regular expressions if defined inside routes: For instance "/users/{username: [a-zA-Z][a-zA-Z_0-9]}" becomes "/users/([a-zA-Z][a-zA-Z_0-9])"
        The converted regex with default matching regex - or the regex specified by the user.