public static UaiRoute findValidRoute(final HttpServerExchange httpServerExchange) {
        final List<UaiRoute> orderedList = getSortedRouteByKey(httpServerExchange);

        if (orderedList.isEmpty()) {
            final String errorText = String.format(
                URI_NOT_FOUND_MESSAGE,
                httpServerExchange.getRequestURI(),
                httpServerExchange.getRequestMethod()
            );
            ExceptionUtil.logBeforeThrowing(new IllegalArgumentException(errorText));
        }

        for (UaiRoute uaiRoute : orderedList) {

            final RequestAnalysisResult validRequest = isValidRequest(uaiRoute.getRequest(), httpServerExchange);

            if (validRequest.isValid()) {
                return uaiRoute;
            }

            if (validRequest.isAbortTheRequest()) {
                break;
            }
        }

        Log.warnFormatted(INVALID_DATA_MESSAGE);

        throw new IllegalArgumentException(INVALID_DATA_MESSAGE);
    }
public static UaiRoute findValidRoute ( final HttpServerExchange httpServerExchange ) { final List < UaiRoute > orderedList = getSortedRouteByKey ( httpServerExchange ) ; if ( orderedList . isEmpty ( ) ) { final String errorText = String . format ( URI_NOT_FOUND_MESSAGE , httpServerExchange . getRequestURI ( ) , httpServerExchange . getRequestMethod ( ) ) ; ExceptionUtil . logBeforeThrowing ( new IllegalArgumentException ( errorText ) ) ; } for ( UaiRoute uaiRoute : orderedList ) { final RequestAnalysisResult validRequest = isValidRequest ( uaiRoute . getRequest ( ) , httpServerExchange ) ; if ( validRequest . isValid ( ) ) { return uaiRoute ; } if ( validRequest . isAbortTheRequest ( ) ) { break ; } } Log . warnFormatted ( INVALID_DATA_MESSAGE ) ; throw new IllegalArgumentException ( INVALID_DATA_MESSAGE ) ; }
This method will return the route of the received request.
It will check for the same queryParam and header
We can have URLs like:
http://uaimockserver.com?queryParam=A returns 201
http://uaimockserver.com?queryParam=B returns 204

@param httpServerExchange the current request
@return the route.