|
1 | 1 | package org.rest.controller.discovery; |
2 | 2 |
|
| 3 | +import java.net.URI; |
| 4 | + |
| 5 | +import javax.servlet.http.HttpServletRequest; |
| 6 | +import javax.servlet.http.HttpServletResponse; |
| 7 | + |
| 8 | +import org.rest.common.util.RESTURIUtil; |
| 9 | +import org.rest.integration.util.HttpConstants; |
3 | 10 | import org.springframework.http.HttpStatus; |
4 | 11 | import org.springframework.stereotype.Controller; |
5 | 12 | import org.springframework.web.bind.annotation.RequestMapping; |
6 | 13 | import org.springframework.web.bind.annotation.RequestMethod; |
7 | | -import org.springframework.web.bind.annotation.ResponseBody; |
8 | 14 | import org.springframework.web.bind.annotation.ResponseStatus; |
| 15 | +import org.springframework.web.util.UriTemplate; |
9 | 16 |
|
10 | 17 | /** |
11 | 18 | * @author eugenp |
12 | 19 | */ |
13 | 20 | @Controller |
14 | 21 | final class DiscoveryController{ |
15 | 22 |
|
16 | | - public DiscoveryController(){ |
17 | | - super(); |
18 | | - } |
19 | | - |
20 | 23 | // API |
21 | 24 |
|
22 | | - @RequestMapping( value = "",method = RequestMethod.GET ) |
23 | | - @ResponseBody |
| 25 | + @RequestMapping( value = "admin",method = RequestMethod.GET ) |
24 | 26 | @ResponseStatus( value = HttpStatus.NO_CONTENT ) |
25 | | - public final String root(){ |
26 | | - return "/foo"; |
| 27 | + public final void adminRoot( final HttpServletRequest request, final HttpServletResponse response ){ |
| 28 | + final String rootUri = request.getRequestURL().toString(); |
| 29 | + |
| 30 | + final URI fooUri = new UriTemplate( "{rootUri}/{resource}" ).expand( rootUri, "foo" ); |
| 31 | + final String linkToFoo = RESTURIUtil.createLinkHeader( fooUri.toASCIIString(), RESTURIUtil.REL_COLLECTION ); |
| 32 | + final String linkToTest = RESTURIUtil.createLinkHeader( "test", RESTURIUtil.REL_COLLECTION ); |
| 33 | + |
| 34 | + response.addHeader( HttpConstants.LINK_HEADER, RESTURIUtil.gatherLinkHeaders( linkToFoo, linkToTest ) ); |
27 | 35 | } |
28 | 36 |
|
29 | 37 | } |
0 commit comments