Skip to content

Commit

Permalink
DATAREST-1540 - Improvements in HandlerMapping implementation for Spr…
Browse files Browse the repository at this point in the history
…ing 5.3.

We now use Spring's path prefix capabilities to apply Spring Data REST's base path to its mappings. This was previously implemented by tweaking the matching conditions.

We now also pick up Spring 5.3's PathPatternParser and apply that to the custom HandlerMapping implementations we register.

Moved DelegatingHandlerMapping into the configuration package to be able to keep it around in package scope.

Deprecated RepositoryRestConfiguration.getBaseUri() as we have only supported paths for quite a while now. Moved all client code to ….getBasePath() instead.
  • Loading branch information
odrotbohm committed Jul 1, 2020
1 parent 8992e21 commit d7f36b1
Show file tree
Hide file tree
Showing 11 changed files with 111 additions and 500 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
@SuppressWarnings("deprecation")
public class RepositoryRestConfiguration {

private static final URI NO_URI = URI.create("");
static final URI NO_URI = URI.create("");

private URI baseUri = NO_URI;
private URI basePath = NO_URI;
Expand Down Expand Up @@ -109,7 +109,9 @@ public RepositoryRestConfiguration(ProjectionDefinitionConfiguration projectionC
* The base URI against which the exporter should calculate its links.
*
* @return The base URI.
* @deprecated use {@link #getBasePath()} instead.
*/
@Deprecated
public URI getBaseUri() {
return basePath != NO_URI ? basePath : baseUri;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.rest.tests.AbstractControllerIntegrationTests;
import org.springframework.data.rest.tests.mongodb.MongoDbRepositoryConfig;
import org.springframework.data.rest.webmvc.support.DelegatingHandlerMapping;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerExecutionChain;
import org.springframework.web.servlet.HandlerMapping;

/**
* Integration tests for {@link BasePathAwareHandlerMapping}.
Expand All @@ -36,7 +36,7 @@
@ContextConfiguration(classes = MongoDbRepositoryConfig.class)
public class RepositoryRestHandlerMappingIntegrationTests extends AbstractControllerIntegrationTests {

@Autowired DelegatingHandlerMapping mapping;
@Autowired HandlerMapping mapping;

@Test // DATAREST-617
public void usesMethodsWithoutProducesClauseForGeneralJsonRequests() throws Exception {
Expand Down
Loading

0 comments on commit d7f36b1

Please sign in to comment.