Class ConsumingWebEndpointMappingAdapter

  • All Implemented Interfaces:
    RequestPredicateVisitorAdapter, RouterFunctionVisitorAdapter, java.lang.reflect.InvocationHandler, org.springframework.web.reactive.function.server.RouterFunctions.Visitor

    public class ConsumingWebEndpointMappingAdapter
    extends java.lang.Object
    implements RequestPredicateVisitorAdapter, RouterFunctionVisitorAdapter
    The adapter class of RequestPredicateVisitorAdapter and RouterFunctionVisitorAdapter to consume the WebEndpointMappings generated during the visiting process.

    This class is designed to traverse Spring WebFlux router functions and their associated request predicates, collecting metadata about web endpoints. It implements both visitor interfaces to capture information such as HTTP methods, path patterns, headers, and query parameters.

    Example Usage

    
     // Create a consumer to handle the generated WebEndpointMappings
     Consumer<WebEndpointMapping> mappingConsumer = mapping -> {
         System.out.println("Endpoint: " + mapping.getEndpoint());
         System.out.println("Patterns: " + Arrays.toString(mapping.getPatterns()));
         System.out.println("Methods: " + Arrays.toString(mapping.getMethods()));
     };
    
     // Create the adapter
     ConsumingWebEndpointMappingAdapter adapter = new ConsumingWebEndpointMappingAdapter(mappingConsumer);
    
     // Visit a router function to collect endpoint mappings
     RouterFunction<?> routerFunction = ...; // your router function
     routerFunction.accept(adapter);
     
    Since:
    1.0.0
    Author:
    Mercy
    See Also:
    RequestPredicateVisitorAdapter, RouterFunctionVisitorAdapter, WebEndpointMapping
    • Constructor Detail

      • ConsumingWebEndpointMappingAdapter

        public ConsumingWebEndpointMappingAdapter​(java.util.function.Consumer<io.microsphere.spring.web.metadata.WebEndpointMapping<?>> webEndpointMappingConsumer)
      • ConsumingWebEndpointMappingAdapter

        public ConsumingWebEndpointMappingAdapter​(java.util.function.Consumer<io.microsphere.spring.web.metadata.WebEndpointMapping<?>> webEndpointMappingConsumer,
                                                  java.lang.Object source)
    • Method Detail

      • method

        public void method​(java.util.Set<org.springframework.http.HttpMethod> methods)
        Description copied from interface: RequestPredicateVisitorAdapter
        Receive notification of an HTTP method predicate.
        Specified by:
        method in interface RequestPredicateVisitorAdapter
        Parameters:
        methods - the HTTP methods that make up the predicate
        See Also:
        RequestPredicates.method(HttpMethod), RequestPredicates.Visitor.method(Set)
      • path

        public void path​(java.lang.String pattern)
        Description copied from interface: RequestPredicateVisitorAdapter
        Receive notification of a path predicate.
        Specified by:
        path in interface RequestPredicateVisitorAdapter
        Parameters:
        pattern - the path pattern that makes up the predicate
        See Also:
        RequestPredicates.path(String), RequestPredicates.Visitor.path(String)
      • header

        public void header​(java.lang.String name,
                           java.lang.String value)
        Description copied from interface: RequestPredicateVisitorAdapter
        Receive notification of an HTTP header predicate.
        Specified by:
        header in interface RequestPredicateVisitorAdapter
        Parameters:
        name - the name of the HTTP header to check
        value - the desired value of the HTTP header
        See Also:
        RequestPredicates.headers(Predicate), RequestPredicates.contentType(MediaType...), RequestPredicates.accept(MediaType...), RequestPredicates.Visitor.header(String, String)
      • queryParam

        public void queryParam​(java.lang.String name,
                               java.lang.String value)
        Description copied from interface: RequestPredicateVisitorAdapter
        Receive notification of a query parameter predicate.
        Specified by:
        queryParam in interface RequestPredicateVisitorAdapter
        Parameters:
        name - the name of the query parameter
        value - the desired value of the parameter
        See Also:
        RequestPredicates.queryParam(String, String), RequestPredicates.Visitor.queryParam(String, String)
      • startNested

        public void startNested​(org.springframework.web.reactive.function.server.RequestPredicate predicate)
        Specified by:
        startNested in interface org.springframework.web.reactive.function.server.RouterFunctions.Visitor
        Specified by:
        startNested in interface RouterFunctionVisitorAdapter
      • endNested

        public void endNested​(org.springframework.web.reactive.function.server.RequestPredicate predicate)
        Specified by:
        endNested in interface org.springframework.web.reactive.function.server.RouterFunctions.Visitor
        Specified by:
        endNested in interface RouterFunctionVisitorAdapter
      • route

        public void route​(org.springframework.web.reactive.function.server.RequestPredicate predicate,
                          org.springframework.web.reactive.function.server.HandlerFunction<?> handlerFunction)
        Specified by:
        route in interface org.springframework.web.reactive.function.server.RouterFunctions.Visitor
        Specified by:
        route in interface RouterFunctionVisitorAdapter