1
1
package org .restexpress .example .blogging .controller ;
2
2
3
3
import static com .strategicgains .repoexpress .adapter .Identifiers .UUID ;
4
- import io .netty .handler .codec .http .HttpMethod ;
5
4
6
5
import java .util .List ;
7
6
20
19
import org .restexpress .query .QueryOrders ;
21
20
import org .restexpress .query .QueryRanges ;
22
21
23
- import com .strategicgains .hyperexpress .HyperExpress ;
24
- import com .strategicgains .hyperexpress .builder .TokenBinder ;
25
- import com .strategicgains .hyperexpress .builder .TokenResolver ;
22
+ import com .strategicgains .hyperexpress .builder .DefaultTokenResolver ;
23
+ import com .strategicgains .hyperexpress .builder .DefaultUrlBuilder ;
26
24
import com .strategicgains .hyperexpress .builder .UrlBuilder ;
27
25
import com .strategicgains .repoexpress .util .UuidConverter ;
28
26
import com .strategicgains .syntaxe .ValidationEngine ;
29
27
28
+ import io .netty .handler .codec .http .HttpMethod ;
29
+
30
30
public class BlogEntryController
31
31
{
32
- private static final UrlBuilder LOCATION_BUILDER = new UrlBuilder ();
32
+ private static final UrlBuilder LOCATION_BUILDER = new DefaultUrlBuilder ();
33
33
private BlogEntryRepository blogEntries ;
34
34
private BlogRepository blogs ;
35
35
@@ -52,13 +52,9 @@ public BlogEntry create(Request request, Response response)
52
52
// Construct the response for create...
53
53
response .setResponseCreated ();
54
54
55
- // Bind the resource with link URL tokens, etc. here...
56
- TokenResolver resolver = HyperExpress .bind (Constants .Url .BLOG_ENTRY_ID_PARAMETER , UUID .format (saved .getUuid ()))
57
- .bind (Constants .Url .BLOG_ID_PARAMETER , UUID .format (saved .getBlogId ()));
58
-
59
55
// Include the Location header...
60
56
String locationPattern = request .getNamedUrl (HttpMethod .GET , Constants .Routes .BLOG_ENTRY_READ_ROUTE );
61
- response .addLocationHeader (LOCATION_BUILDER .build (locationPattern , resolver ));
57
+ response .addLocationHeader (LOCATION_BUILDER .build (locationPattern , new DefaultTokenResolver () ));
62
58
63
59
// Return the newly-created item...
64
60
return saved ;
@@ -68,11 +64,6 @@ public BlogEntry read(Request request, Response response)
68
64
{
69
65
String id = request .getHeader (Constants .Url .BLOG_ENTRY_ID_PARAMETER , "No BlogEntry ID supplied" );
70
66
BlogEntry entity = blogEntries .read (UUID .parse (id ));
71
-
72
- // enrich the resource with links, etc. here...
73
- HyperExpress .bind (Constants .Url .BLOG_ENTRY_ID_PARAMETER , UUID .format (entity .getUuid ()))
74
- .bind (Constants .Url .BLOG_ID_PARAMETER , UUID .format (entity .getBlogId ()));
75
-
76
67
return entity ;
77
68
}
78
69
@@ -87,17 +78,6 @@ public List<BlogEntry> readAll(Request request, Response response)
87
78
List <BlogEntry > results = blogEntries .readAll (filter , range , order );
88
79
response .setCollectionResponse (range , results .size (), blogEntries .count (filter ));
89
80
90
- // Bind the resources in the collection with link URL tokens, etc. here...
91
- HyperExpress .tokenBinder (new TokenBinder <BlogEntry >()
92
- {
93
- @ Override
94
- public void bind (BlogEntry entity , TokenResolver resolver )
95
- {
96
- resolver .bind (Constants .Url .BLOG_ENTRY_ID_PARAMETER , UUID .format (entity .getUuid ()))
97
- .bind (Constants .Url .BLOG_ID_PARAMETER , UUID .format (entity .getBlogId ()));
98
- }
99
- });
100
-
101
81
return results ;
102
82
}
103
83
0 commit comments