Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ protected ItemDeprecation resolveItemDeprecation(MetadataGenerationEnvironment e

@Override
protected boolean isMarkedAsNested(MetadataGenerationEnvironment environment) {
return environment.getNestedConfigurationPropertyAnnotation(this.recordComponent) != null;
return environment.getNestedConfigurationPropertyAnnotation(this.recordComponent) != null
|| environment.getNestedConfigurationPropertyAnnotation(getGetter()) != null;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public static EndpointServerWebExchangeMatcher to(String... endpoints) {
* @return the configured {@link ServerWebExchangeMatcher}
*/
public static LinksServerWebExchangeMatcher toLinks() {
return new LinksServerWebExchangeMatcher();
return new LinksServerWebExchangeMatcher(null);
}

/**
Expand Down Expand Up @@ -344,7 +344,7 @@ protected ServerWebExchangeMatcher createDelegate(PathMappedEndpoints endpoints)
List<ServerWebExchangeMatcher> delegateMatchers = getDelegateMatchers(paths, this.httpMethod);
String linksPath = getLinksPath(endpoints.getBasePath());
if (this.includeLinks && linksPath != null) {
delegateMatchers.add(new LinksServerWebExchangeMatcher());
delegateMatchers.add(new LinksServerWebExchangeMatcher(this.httpMethod));
}
if (delegateMatchers.isEmpty()) {
return EMPTY_MATCHER;
Expand Down Expand Up @@ -373,18 +373,21 @@ public String toString() {
*/
public static final class LinksServerWebExchangeMatcher extends AbstractWebExchangeMatcher<WebEndpointProperties> {

private LinksServerWebExchangeMatcher() {
private final @Nullable HttpMethod httpMethod;

private LinksServerWebExchangeMatcher(@Nullable HttpMethod httpMethod) {
super(WebEndpointProperties.class);
this.httpMethod = httpMethod;
}

@Override
protected ServerWebExchangeMatcher createDelegate(WebEndpointProperties properties) {
String linksPath = getLinksPath(properties.getBasePath());
if (linksPath != null) {
List<ServerWebExchangeMatcher> linksMatchers = new ArrayList<>();
linksMatchers.add(new PathPatternParserServerWebExchangeMatcher(linksPath));
linksMatchers.add(new PathPatternParserServerWebExchangeMatcher(linksPath, this.httpMethod));
if (!linksPath.endsWith("/")) {
linksMatchers.add(new PathPatternParserServerWebExchangeMatcher(linksPath + "/"));
linksMatchers.add(new PathPatternParserServerWebExchangeMatcher(linksPath + "/", this.httpMethod));
}
return new OrServerWebExchangeMatcher(linksMatchers);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,11 @@ protected final List<RequestMatcher> getDelegateMatchers(RequestMatcherFactory r
}

protected List<RequestMatcher> getLinksMatchers(RequestMatcherFactory requestMatcherFactory,
RequestMatcherProvider matcherProvider, String linksPath) {
RequestMatcherProvider matcherProvider, String linksPath, @Nullable HttpMethod httpMethod) {
List<RequestMatcher> linksMatchers = new ArrayList<>();
linksMatchers.add(requestMatcherFactory.antPath(matcherProvider, null, linksPath));
linksMatchers.add(requestMatcherFactory.antPath(matcherProvider, httpMethod, linksPath));
if (!linksPath.endsWith("/")) {
linksMatchers.add(requestMatcherFactory.antPath(matcherProvider, null, linksPath, "/"));
linksMatchers.add(requestMatcherFactory.antPath(matcherProvider, httpMethod, linksPath, "/"));
}
return linksMatchers;
}
Expand Down Expand Up @@ -357,7 +357,7 @@ protected RequestMatcher createDelegate(WebApplicationContext context,
String basePath = endpoints.getBasePath();
String linksPath = getLinksPath(context, basePath);
if (this.includeLinks && linksPath != null) {
delegateMatchers.addAll(getLinksMatchers(requestMatcherFactory, matcherProvider, linksPath));
delegateMatchers.addAll(getLinksMatchers(requestMatcherFactory, matcherProvider, linksPath, this.httpMethod));
}
if (delegateMatchers.isEmpty()) {
return EMPTY_MATCHER;
Expand Down Expand Up @@ -393,7 +393,7 @@ protected RequestMatcher createDelegate(WebApplicationContext context,
String linksPath = getLinksPath(context, properties.getBasePath());
if (linksPath != null) {
return new OrRequestMatcher(
getLinksMatchers(requestMatcherFactory, getRequestMatcherProvider(context), linksPath));
getLinksMatchers(requestMatcherFactory, getRequestMatcherProvider(context), linksPath, null));
}
return EMPTY_MATCHER;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ void toAnyEndpointWithHttpMethodShouldRespectRequestMethod() {
ServerWebExchangeMatcher matcher = EndpointRequest.toAnyEndpoint().withHttpMethod(HttpMethod.POST);
assertMatcher(matcher, "/actuator").matches(HttpMethod.POST, "/actuator/foo");
assertMatcher(matcher, "/actuator").doesNotMatch(HttpMethod.GET, "/actuator/foo");
assertMatcher(matcher, "/actuator").matches(HttpMethod.POST, "/actuator");
assertMatcher(matcher, "/actuator").doesNotMatch(HttpMethod.GET, "/actuator");
assertMatcher(matcher, "/actuator").matches(HttpMethod.POST, "/actuator/");
assertMatcher(matcher, "/actuator").doesNotMatch(HttpMethod.GET, "/actuator/");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ void toAnyEndpointWithHttpMethodShouldRespectRequestMethod() {
.withHttpMethod(HttpMethod.POST);
assertMatcher(matcher, "/actuator").matches(HttpMethod.POST, "/actuator/foo");
assertMatcher(matcher, "/actuator").doesNotMatch(HttpMethod.GET, "/actuator/foo");
assertMatcher(matcher, "/actuator").matches(HttpMethod.POST, "/actuator");
assertMatcher(matcher, "/actuator").doesNotMatch(HttpMethod.GET, "/actuator");
assertMatcher(matcher, "/actuator").matches(HttpMethod.POST, "/actuator/");
assertMatcher(matcher, "/actuator").doesNotMatch(HttpMethod.GET, "/actuator/");
}

@Test
Expand Down