protected Route recognize ( String uri , HttpMethod httpMethod ) throws ClassLoadException { if ( uri . endsWith ( "/" ) && uri . length ( ) > 1 ) { uri = uri . substring ( 0 , uri . length ( ) - 1 ) ; } ControllerPath controllerPath = getControllerPath ( uri ) ; Route route = matchCustom ( uri , controllerPath , httpMethod ) ; if ( route == null ) { //proceed to built-in routes if ( controllerPath . getControllerName ( ) == null ) { return null ; } String controllerClassName = getControllerClassName ( controllerPath ) ; AppController controller = createControllerInstance ( controllerClassName ) ; if ( uri . equals ( "/" ) && rootControllerName != null ) { route = new Route ( controller , "index" , httpMethod ) ; } else { route = controller . restful ( ) ? matchRestful ( uri , controllerPath , httpMethod , controller ) : matchStandard ( uri , controllerPath , controller , httpMethod ) ; } } if ( route != null ) { route . setIgnoreSpecs ( ignoreSpecs ) ; } else { logger . error ( "Failed to recognize URL: '" + uri + "'" ) ; throw new RouteException ( "Failed to map resource to URI: " + uri ) ; } return route ; }
This is a main method for recognizing a route to a controller ; used when a request is received .