public static boolean start ( HttpServerExchange httpServerExchange ) { // Get the matcher corresponding to the current request type. PathTemplateMatcher < String > pathTemplateMatcher = methodToMatcherMap . get ( httpServerExchange . getRequestMethod ( ) ) ; if ( pathTemplateMatcher != null ) { // Match the current request path to the configured paths. PathTemplateMatcher . PathMatchResult < String > result = pathTemplateMatcher . match ( httpServerExchange . getRequestPath ( ) ) ; if ( result != null ) { // Found a match, configure and return true; // Add path variables to query params. httpServerExchange . putAttachment ( ATTACHMENT_KEY , new io . undertow . util . PathTemplateMatch ( result . getMatchedTemplate ( ) , result . getParameters ( ) ) ) ; for ( Map . Entry < String , String > entry : result . getParameters ( ) . entrySet ( ) ) { // the values shouldn't be added to query param. but this is left as it was to keep backward compatability httpServerExchange . addQueryParam ( entry . getKey ( ) , entry . getValue ( ) ) ; // put values in path param map httpServerExchange . addPathParam ( entry . getKey ( ) , entry . getValue ( ) ) ; } String id = result . getValue ( ) ; httpServerExchange . putAttachment ( CHAIN_ID , id ) ; httpServerExchange . putAttachment ( CHAIN_SEQ , 0 ) ; return true ; } } return false ; }
On the first step of the request match the request against the configured paths . If the match is successful store the chain id within the exchange . Otherwise return false .