Class ResponseDecorator
java.lang.Object
se.fortnox.reactivewizard.jaxrs.response.ResponseDecorator
Allows you to return response headers together with your result.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic class -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static <T> reactor.core.publisher.Flux<T>apply(reactor.core.publisher.Flux<T> output, JaxRsResult<T> result) static <T> ResponseDecorator.DecoratedResponseBuilder<T>of(T value) Creates a DecoratedResponseBuilder for the supplied Observable.static <T> rx.Observable<T>withHeaders(rx.Observable<T> value, Map<String, String> headers) Use this to wrap your Observable with some headers.
-
Constructor Details
-
ResponseDecorator
public ResponseDecorator()
-
-
Method Details
-
withHeaders
@Nonnull public static <T> rx.Observable<T> withHeaders(@Nonnull rx.Observable<T> value, @Nonnull Map<String, String> headers) Use this to wrap your Observable with some headers. This must be the last decoration before returning from your resource. Any Observable operator applied after this will remove the headers.- Type Parameters:
T- is the type of value- Parameters:
value- is the responseheaders- is your headers- Returns:
- the value, decorated with headers.
-
of
Creates a DecoratedResponseBuilder for the supplied Observable.Use
ResponseDecorator.DecoratedResponseBuilder.withHeaders(java.util.Map<java.lang.String, java.lang.String>)andResponseDecorator.DecoratedResponseBuilder.withStatus(io.netty.handler.codec.http.HttpResponseStatus)to decorate your response. UseResponseDecorator.DecoratedResponseBuilder.build()to create the decorated Observable.This must be the last decoration before returning from your resource. Any Observable operator applied after this will remove the headers.
Example:
ResponseDecorator.of(just("body")) .withHeaders(Map.of("Location", "/somewhere-else")) .withStatus(HttpResponseStatus.MOVED_PERMANENTLY) .build();- Type Parameters:
T- is the type of value- Parameters:
value- is the response- Returns:
- DecoratedResponseBuilder<T>
-
apply
protected static <T> reactor.core.publisher.Flux<T> apply(@Nonnull reactor.core.publisher.Flux<T> output, @Nonnull JaxRsResult<T> result)
-