public static HttpHandler createRootHandler ( List < MappedEndpoint > mappedEndpoints , List < Interceptor > rootInterceptors , List < Interceptor > endpointInterceptors , ExceptionMapper exceptionMapper , String basePath , boolean httpTracer ) { final RoutingHandler routingRestHandler = new HttpRootHandler ( false ) ; final PathTemplateHandler websocketHandler = Handlers . pathTemplate ( false ) ; HttpHandler staticHandler = null ; for ( MappedEndpoint me : mappedEndpoints ) { if ( MappedEndpoint . Type . REST . equals ( me . type ) ) { HttpHandler httpDispatcher = new BlockingHandler ( new HttpDispatcher ( new ConnegHandler ( new InterceptorHandler ( me . handler , endpointInterceptors ) , me . mediaTypes ) , exceptionMapper ) ) ; String endpointPath = HandlerUtil . BASE_PATH . equals ( basePath ) ? me . url : basePath + me . url ; HttpHandler httpHandler = wrapCompressionHandler ( httpDispatcher , me ) ; routingRestHandler . add ( me . method , endpointPath , httpHandler ) ; } if ( MappedEndpoint . Type . MULTIPART . equals ( me . type ) ) { HttpHandler httpDispatcher = new BlockingHandler ( new HttpDispatcher ( new ConnegHandler ( new InterceptorHandler ( me . handler , endpointInterceptors ) , me . mediaTypes ) , exceptionMapper ) ) ; String endpointPath = HandlerUtil . BASE_PATH . equals ( basePath ) ? me . url : basePath + me . url ; HttpHandler httpHandler = wrapCompressionHandler ( httpDispatcher , me ) ; routingRestHandler . add ( me . method , endpointPath , httpHandler ) ; } if ( MappedEndpoint . Type . SSE . equals ( me . type ) ) { InterceptorHandler interceptorHandler = new InterceptorHandler ( me . handler , endpointInterceptors ) ; HttpHandler httpHandler = wrapCompressionHandler ( interceptorHandler , me ) ; String endpointPath = HandlerUtil . BASE_PATH . equals ( basePath ) ? me . url : basePath + me . url ; routingRestHandler . add ( me . method , endpointPath , httpHandler ) ; } if ( MappedEndpoint . Type . WS . equals ( me . type ) ) { InterceptorHandler interceptorHandler = new InterceptorHandler ( me . handler , endpointInterceptors ) ; HttpHandler httpHandler = wrapCompressionHandler ( interceptorHandler , me ) ; websocketHandler . add ( me . url , httpHandler ) ; } if ( MappedEndpoint . Type . STATIC . equals ( me . type ) ) { staticHandler = wrapCompressionHandler ( me . handler , me ) ; } } HttpHandler resolved = resolveHandlers ( routingRestHandler , websocketHandler , staticHandler , mappedEndpoints ) ; HttpHandler root = wrapRootInterceptorHandler ( resolved , rootInterceptors ) ; HttpHandler handler = wrapRequestDump ( root , httpTracer ) ; // handler = wrapServerName(handler); return Handlers . gracefulShutdown ( handler ) ; }
chain of responsibility