Changed the way baseUri is calculated. Changed tests to accommodate new method signatures, fix failing tests.

* Added a configuration property to `RepositoryRestConfiguration` for deployments behind a proxy which do not know the external URL to use as the baseUri for links.
* Changed the way the baseUri is injected into the controller by introducing a `BaseUriMethodArgumentResolver` to inject the proper baseUri (either the one from the configuration, or the one from the request if that's not specified).
This commit is contained in:
Jon Brisbin
2012-10-01 09:52:46 -05:00
committed by Jon Brisbin
parent 697f39d5b0
commit df3b60ba41
15 changed files with 169 additions and 96 deletions

View File

@@ -2,6 +2,9 @@
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
<persistence-unit name="jpa.sample">
<class>org.springframework.data.rest.test.webmvc.Address</class>
<class>org.springframework.data.rest.test.webmvc.Child</class>
<class>org.springframework.data.rest.test.webmvc.Customer</class>
<class>org.springframework.data.rest.test.webmvc.CustomerTracker</class>
<class>org.springframework.data.rest.test.webmvc.Family</class>
<class>org.springframework.data.rest.test.webmvc.Person</class>
<class>org.springframework.data.rest.test.webmvc.Profile</class>

View File

@@ -8,7 +8,8 @@
<bean id="config" class="org.springframework.data.rest.webmvc.RepositoryRestConfiguration"
p:jsonpParamName="callback"
p:jsonpOnErrParamName="errback">
p:jsonpOnErrParamName="errback"
p:baseUri="http://localhost:8080">
<property name="domainTypeToRepositoryMappings">
<map key-type="java.lang.Class" value-type="java.lang.Class">
<entry key="org.springframework.data.rest.test.webmvc.Person"

View File

@@ -9,7 +9,7 @@ curl -v -d "http://localhost:8080/address/1" -H "Content-Type: text/uri-list" ht
curl -v -d "http://localhost:8080/people/1" -X PUT -H "Content-Type: text/uri-list" http://localhost:8080/address/1/person
curl -v -d '{"postalCode":"54321","province":"MO","lines":["2 W 1st St."],"city":"Univille","person": {"href":"http://localhost:8080/people/2"}}' -H "Content-Type: application/json" http://localhost:8080/address
curl -v -d "http://localhost:8080/address/2" -H "Content-Type: text/uri-list" http://localhost:8080/people/2/addresses
curl -v -d '{"type" : "twitter", "url": "#!/johndoe"}' -H "Content-Type: application/json" http://localhost:8080/profile
curl -v -d "http://localhost:8080/profile/1" -H "Content-Type: text/uri-list" http://localhost:8080/people/1/profiles
curl -v -d '{"type" : "facebook", "url": "/janedoe"}' -H "Content-Type: application/json" http://localhost:8080/profile
curl -v -d '{"links": [{"rel":"facebook", "href": "http://localhost:8080/profile/2"}]}' -H "Content-Type: application/json" http://localhost:8080/people/2/profiles
curl -v -d '{"type" : "twitter", "url": "#!/johndoe", "person": {"href": "http://localhost:8080/people/1"}}' -H "Content-Type: application/json" http://localhost:8080/profile
#curl -v -d "http://localhost:8080/profile/1" -H "Content-Type: text/uri-list" http://localhost:8080/people/1/profiles
curl -v -d '{"type" : "facebook", "url": "/janedoe", "person": {"href": "http://localhost:8080/people/2"}}' -H "Content-Type: application/json" http://localhost:8080/profile
#curl -v -d '{"links": [{"rel":"facebook", "href": "http://localhost:8080/profile/2"}]}' -H "Content-Type: application/json" http://localhost:8080/people/2/profiles