|
1 | 1 | /*
|
2 |
| - * Copyright 2012-2025 the original author or authors. |
| 2 | + * Copyright 2012-2023 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
16 | 16 |
|
17 | 17 | package org.springframework.boot.actuate.web.mappings.reactive;
|
18 | 18 |
|
| 19 | +import java.util.ArrayList; |
19 | 20 | import java.util.Arrays;
|
20 | 21 | import java.util.HashMap;
|
21 | 22 | import java.util.List;
|
22 | 23 | import java.util.Map;
|
23 | 24 | import java.util.Map.Entry;
|
| 25 | +import java.util.function.Function; |
24 | 26 | import java.util.stream.Stream;
|
25 | 27 |
|
| 28 | +import reactor.core.publisher.Mono; |
26 | 29 |
|
27 | 30 | import org.springframework.aot.hint.BindingReflectionHintsRegistrar;
|
28 | 31 | import org.springframework.aot.hint.RuntimeHints;
|
|
32 | 35 | import org.springframework.boot.actuate.web.mappings.reactive.DispatcherHandlersMappingDescriptionProvider.DispatcherHandlersMappingDescriptionProviderRuntimeHints;
|
33 | 36 | import org.springframework.context.ApplicationContext;
|
34 | 37 | import org.springframework.context.annotation.ImportRuntimeHints;
|
| 38 | +import org.springframework.core.io.Resource; |
35 | 39 | import org.springframework.web.method.HandlerMethod;
|
36 | 40 | import org.springframework.web.reactive.DispatcherHandler;
|
37 | 41 | import org.springframework.web.reactive.HandlerMapping;
|
| 42 | +import org.springframework.web.reactive.function.server.HandlerFunction; |
| 43 | +import org.springframework.web.reactive.function.server.RequestPredicate; |
38 | 44 | import org.springframework.web.reactive.function.server.RouterFunction;
|
| 45 | +import org.springframework.web.reactive.function.server.RouterFunctions.Visitor; |
| 46 | +import org.springframework.web.reactive.function.server.ServerRequest; |
39 | 47 | import org.springframework.web.reactive.function.server.support.RouterFunctionMapping;
|
40 | 48 | import org.springframework.web.reactive.handler.AbstractUrlHandlerMapping;
|
41 | 49 | import org.springframework.web.reactive.result.method.RequestMappingInfo;
|
@@ -150,7 +158,41 @@ public List<DispatcherHandlerMappingDescription> describe(RouterFunctionMapping
|
150 | 158 | if (routerFunction != null) {
|
151 | 159 | routerFunction.accept(visitor);
|
152 | 160 | }
|
153 |
| - return visitor.getDescriptions(); |
| 161 | + return visitor.descriptions; |
| 162 | + } |
| 163 | + |
| 164 | + } |
| 165 | + |
| 166 | + private static final class MappingDescriptionVisitor implements Visitor { |
| 167 | + |
| 168 | + private final List<DispatcherHandlerMappingDescription> descriptions = new ArrayList<>(); |
| 169 | + |
| 170 | + @Override |
| 171 | + public void startNested(RequestPredicate predicate) { |
| 172 | + } |
| 173 | + |
| 174 | + @Override |
| 175 | + public void endNested(RequestPredicate predicate) { |
| 176 | + } |
| 177 | + |
| 178 | + @Override |
| 179 | + public void route(RequestPredicate predicate, HandlerFunction<?> handlerFunction) { |
| 180 | + DispatcherHandlerMappingDetails details = new DispatcherHandlerMappingDetails(); |
| 181 | + details.setHandlerFunction(new HandlerFunctionDescription(handlerFunction)); |
| 182 | + this.descriptions.add( |
| 183 | + new DispatcherHandlerMappingDescription(predicate.toString(), handlerFunction.toString(), details)); |
| 184 | + } |
| 185 | + |
| 186 | + @Override |
| 187 | + public void resources(Function<ServerRequest, Mono<Resource>> lookupFunction) { |
| 188 | + } |
| 189 | + |
| 190 | + @Override |
| 191 | + public void attributes(Map<String, Object> attributes) { |
| 192 | + } |
| 193 | + |
| 194 | + @Override |
| 195 | + public void unknown(RouterFunction<?> routerFunction) { |
154 | 196 | }
|
155 | 197 |
|
156 | 198 | }
|
|
0 commit comments