Skip to content

Commit

Permalink
micronaut-projects#144 - Use the value of the UriMapping annotation o…
Browse files Browse the repository at this point in the history
…n the element's declaring type instead of Controller.
  • Loading branch information
Mikael Vik committed Feb 17, 2020
1 parent 931e767 commit 68cf893
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import io.micronaut.http.annotation.PathVariable;
import io.micronaut.http.annotation.Produces;
import io.micronaut.http.annotation.QueryValue;
import io.micronaut.http.annotation.UriMapping;
import io.micronaut.http.uri.UriMatchTemplate;
import io.micronaut.http.uri.UriMatchVariable;
import io.micronaut.inject.ast.ClassElement;
Expand Down Expand Up @@ -139,9 +140,9 @@ public void visitMethod(MethodElement element, VisitorContext context) {
return;
}

String controllerValue = element.getValue(Controller.class, String.class).orElse("/");
controllerValue = getPropertyPlaceholderResolver().resolvePlaceholders(controllerValue).orElse(controllerValue);
UriMatchTemplate matchTemplate = UriMatchTemplate.of(controllerValue);
String uriMappingValue = element.getDeclaringType().getValue(UriMapping.class, String.class).orElse("/");
uriMappingValue = getPropertyPlaceholderResolver().resolvePlaceholders(uriMappingValue).orElse(uriMappingValue);
UriMatchTemplate matchTemplate = UriMatchTemplate.of(uriMappingValue);
String methodValue = element.getValue(HttpMethodMapping.class, String.class).orElse("/");
methodValue = getPropertyPlaceholderResolver().resolvePlaceholders(methodValue).orElse(methodValue);
matchTemplate = matchTemplate.nest(methodValue);
Expand Down

0 comments on commit 68cf893

Please sign in to comment.