You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -133,6 +134,35 @@ public Mono<HalResourceWrapper<OrderDTO, Void>> getOrder(@PathVariable int order
133
134
}
134
135
}
135
136
```
137
+
### Response Types
138
+
hateoflux provides specialized response types (basically reactive `ResponseEntity`s) to handle different resource scenarios in reactive applications. The following controller method is from the previous example now altered however altered to return a reactive HTTP response, while preserving the same body:
139
+
140
+
hateoflux provides specialized response types (essentially reactive `ResponseEntity`s) to handle different resource scenarios in reactive applications. Here's the previous controller example modified to return a reactive HTTP response while preserving the same body:
Mono<HalResourceWrapper<OrderDTO, Void>> order = orderService.getOrder(orderId)
147
+
.map(order ->HalResourceWrapper.wrap(order)
148
+
.withLinks(
149
+
Link.of("orders/{orderId}/shipment")
150
+
.expand(orderId)
151
+
.withRel("shipment"),
152
+
Link.linkAsSelfOf("orders/"+ orderId)
153
+
));
154
+
155
+
returnHalResourceResponse.ok(order)
156
+
.withContentType(MediaType.APPLICATION_JSON)
157
+
.withHeader("Custom-Header", "value");
158
+
}
159
+
```
160
+
The library provides three response types for different scenarios:
161
+
162
+
*`HalResourceResponse`: For single HAL resources (shown above)
163
+
*`HalMultiResourceResponse`: For streaming multiple resources individually
164
+
*`HalListResponse`: For collections as a single HAL document, including pagination
165
+
136
166
## Advanced Usage
137
167
### Assemblers
138
168
Assemblers in hateoflux reduce boilerplate by handling the wrapping and linking logic. Implement either `FlatHalWrapperAssembler` for resources without embedded entities or `EmbeddingHalWrapperAssembler` for resources with embedded entities.
Explore practical examples and debug them in the [hateoflux-demos](https://github.com/kamillionlabs/hateoflux-demos) repository. Fork the repository and run the applications to see hateoflux in action.
188
218
### Cookbook
189
-
Refer to the [Cookbook: Examples & Use Cases](https://hateoflux.kamillionlabs.de/docs/cookbook.html) for detailed and explained scenarios and code snippets demonstrating various functionalities of hateoflux.
219
+
Refer to the [Cookbook: Examples & Use Cases](https://hateoflux.kamillionlabs.de/cookbook/cookbook.html) for detailed and explained scenarios and code snippets demonstrating various functionalities of hateoflux.
190
220
191
221
## Documentation
192
222
Comprehensive documentation is available at [https://hateoflux.kamillionlabs.de (english)](https://hateoflux.kamillionlabs.de), covering:
193
223
-[What is hateoflux?](https://hateoflux.kamillionlabs.de/)
-[Spring HATEOAS vs. hateoflux](https://hateoflux.kamillionlabs.de/docs/spring-vs-hateoflux.html)
198
-
-[Cookbook: Examples & Use Cases](https://hateoflux.kamillionlabs.de/docs/cookbook.html)
229
+
-[Cookbook: Examples & Use Cases](https://hateoflux.kamillionlabs.de/docs/cookbook/)
199
230
200
231
## Comparison with Spring HATEOAS
201
232
hateoflux is specifically designed for reactive Spring WebFlux applications, offering a more streamlined and maintainable approach compared to Spring HATEOAS in reactive environments. Key differences include:
|**Representation Models**| Uses wrappers and inheritance-based models, requiring manual embedding of resources via inheritance or separate classes. | Uses wrappers exclusively to keep domain models clean and decoupled. |
237
+
|**Response Types**| Uses standard `ResponseEntity` with manual reactive flow handling | Dedicated response types optimized for different resource scenarios |
206
238
|**Assemblers and Boilerplate**| Verbose with manual resource wrapping and link addition. | Simplified with built-in methods; only links need to be specified in assemblers. |
207
239
|**Pagination Handling**| Limited support in reactive environments; requires manual implementation. | Easy pagination with HalListWrapper; handles metadata and navigation links automatically. |
208
240
|**Documentation Support**| Better for Spring MVC; less comprehensive for WebFlux. | Tailored for reactive Spring WebFlux with focused documentation and examples. |
0 commit comments