Commit Graph

157 Commits

Author SHA1 Message Date
Arjen Poutsma d1e0990293 Polishing 2017-04-19 16:49:06 +02:00
Arjen Poutsma 30f61e0c07 Add body(Object) method to ServerResponse.BodyBuilder
This method introduces a new body(Object) to ServerResponse, a shortcut
to body(BodyInserters.fromObject(Object)).

Note that in the implementation of the method, an `instanceof` check is
performed to make sure that the passed argument is not a `Publisher`,
as users should call `body(Publisher, Class)` for sending a reactive
type.

This Publisher-check is also done in the `WebClient`, for the same
reasons.

Issue: SPR-15461
2017-04-19 16:40:23 +02:00
Arjen Poutsma b897f96e0f Use PathRemainingMatchInfo in RequestPredicates
This commit uses the newly introduced PathRemainingMatchInfo
(316a680577) in path-based
RequestPredicates.

Issue: SPR-15419
2017-04-19 10:39:51 +02:00
Rossen Stoyanchev 887e5e50a9 Polish model attribute name checks 2017-04-18 23:10:47 -04:00
Rossen Stoyanchev d78d82c516 Use Conventions for reactive model attribute names
Issue: SPR-14915
2017-04-18 23:00:43 -04:00
Andy Clement 316a680577 Modify getPathRemaining to return remaining path and bound variables
Without this change it was necessary to call getPathRemaining and
then chop up the path and make a call to matchAndExtract to get the
bound variables for the path part that matched. With this change
this is all done in the call to getPathRemaining which returns
an object holding the remaining path and the bound variables.

Issue: SPR-15419
2017-04-18 16:17:44 -07:00
Brian Clozel 88f8df4dce Update Mono.then(Supplier) deprecated calls
Reactor Core has now deprecated the `Mono.then(Supplier)`.
This is now replaced with `Mono.then(Mono.defer(Supplier))`.
2017-04-18 21:11:19 +02:00
Rossen Stoyanchev 3efb76c852 Jackson encoder skips String.class
Jackson2Encoder explicitly disables String from the supported types
consistent with the same change on the decoder side:

0662dbf044

Issue: SPR-15443
2017-04-14 17:21:26 -04:00
Brian Clozel a8d785b87f Move RxNetty support to test scope
The RxNetty runtime support is not meant to be officially supported and
should be restricted to testing purposes only.

Issue: SPR-15444
2017-04-14 19:18:42 +02:00
Sebastien Deleuze 005e85b0f5 Update to latest Reactor 3.1 API changes
Issue: SPR-15318
2017-04-14 13:18:20 +02:00
Sebastien Deleuze e3fae2716e Rename Mono#otherwise[Empty] to switch[onError/IfEmpty]
Issue: SPR-15318
2017-04-13 15:36:34 +02:00
Arjen Poutsma dc279d839b Use refactored CodecConfigurer
This commit changes the `HandlerStrategies` and `ExchangeStrategies`
builders to use the `CodecConfigurer` for configuring Decoder|Encoder
and HttpMessage[Reader|Writer]. Other classes that use `CodecConfigurer`
have also been changed to reflect the refactoring to interfaces.

This commit also removes the ExchangeStrategies methods that take an
application context, as it was too naive approach to simply look up
every message reader and writer in the context.

Issue: SPR-15415, SPR-15435
2017-04-13 11:02:29 +02:00
Sebastien Deleuze 4d9144132e Upgrade to Reactor Core 3.1
Issue: SPR-15318
2017-04-11 18:13:04 +02:00
Rossen Stoyanchev 49ac6d54f7 Apply default content type change to WebFlux
Issue: SPR-15367
2017-04-11 11:54:40 -04:00
Rossen Stoyanchev 3393c10d79 Refactor HttpHeaders "Accept-Language" with Locale 2017-04-11 07:19:07 -04:00
Sebastien Deleuze 23e35c0e1a Handle Jackson InvalidDefinitionException with 5xx status in WebFlux
Issue: SPR-14925
2017-04-11 12:39:09 +02:00
Arjen Poutsma ac27dbea4b Use ServerCodecConfigurer in HandlerStrategies
This commit changes the `HandlerStrategies` builder to use
`ServerCodecConfigurer` for configuring Decoder|Encoder and
HttpMessage[Reader|Writer]. Note that the configurer is not exposed
directly, but wrapped so that `HandlerStrategies` can keep on returning
`this` for a proper builder pattern.

This commit also removes the HandlerStrategies methods that take an
application context, as it was too naive approach to simply look up
every message reader and writer in the context.

Issue: SPR-15415
2017-04-11 11:01:27 +02:00
Arjen Poutsma 82e864b217 Polishing
- Renamed `defaultCodec` to `defaultCodecs`, and `customCodec` to
`customCodecs`
- Added `@Override` annotations where necessary
- Fixed non-parameterized usage for parameterized types.
2017-04-11 11:01:27 +02:00
Sebastien Deleuze d098a4b96b Make CodecException handling consistent
This commit makes CodecException handling consistent between functional
and annotation-based APIs. It now returns by default 4xx status code
for decoding error and 5xx for encoding error + print the error reason
in logs without the full stack trace in both variants.

Issue: SPR-15355
2017-04-10 16:07:56 +02:00
Sebastien Deleuze 9b85c5b636 Rename RouterDsl to RouterFunctionDsl 2017-04-10 10:37:24 +02:00
Sebastien Deleuze 18d8876dc8 Update RouterFunctionExtensions documentation 2017-04-10 10:37:23 +02:00
Juergen Hoeller 5986f881d0 HandlerMethod evaluates ResponseStatus annotation for early caching
Issue: SPR-15227
2017-04-08 15:56:05 +02:00
Rossen Stoyanchev 91977c81ad Support Optional without @RequestParam in WebFlux
The java.util.Optional wrapper should not affect the support for
"request param" arguments with or without the annotation as it
works on the Spring MVC side.
2017-04-07 17:15:07 -04:00
Rossen Stoyanchev 3780d040ee Polish and minor fixes in ViewResolutionResultHandler 2017-04-07 17:15:07 -04:00
Rossen Stoyanchev e4c62cc029 Controller API for view rendering
Issue: SPR-15211
2017-04-07 17:15:07 -04:00
Arjen Poutsma e556aaccee Use PathPattern.getPathRemaining in WebFlux fn
This commit uses the newly introduced
`PathPattern.getPathRemaining(String)` in the functional web framework.
With this change, all path predicates can be used for nested router
functions, so the `pathPrefix` predicate is no longer required and has
been removed.

Issue: SPR-15336
2017-04-07 11:25:15 +02:00
Rossen Stoyanchev b245918574 Fix compiler warning 2017-04-06 16:08:25 -04:00
Rossen Stoyanchev e49d797104 Polish HttpMessageWriterView and view resolution 2017-04-06 14:21:48 -04:00
Rossen Stoyanchev 10aa56aa8d Remove file committed by mistake 2017-04-06 14:20:40 -04:00
Rossen Stoyanchev 43eea41dd6 Polish 2017-04-06 12:54:49 -04:00
Arjen Poutsma 99474376e6 Server HttpMessage[Reader|Writer] in WebFlux fn
This commit introduces support for the server-side methods on
HttpMessageReader and HttpMessageWriter. It does so by introducing an
Optional ServerHttpRequest in BodyInserter.Context, and an Optional
ServerHttpResponse in BodyExtractor.Context. On the client-side, these
optionals return Optional.empty(); on the server-side, they return the
respective server-side messages.

Issue: SPR-15370
2017-04-05 11:36:56 +02:00
Sebastien Deleuze cfc89ebe16 Add WebClient.ResponseSpec Kotlin extensions 2017-04-03 10:41:01 +02:00
Amey Jadiye 472954bbb7 Polish javadoc
Closes gh-1370
2017-04-02 08:06:57 +02:00
Sebastien Deleuze 73b44828e9 Resolve async model attributes in AbstractView
This change allows the functional WebFlux API to support natively
reactive types and also makes it possible for View implementations to
disable async attributes resolution if they want for example take
advantage of stream rendering.

It also makes AbstractView#getModelAttributes() asynchronous.

Issue: SPR-15368
2017-03-30 21:48:45 +02:00
Rossen Stoyanchev 840d7abbf6 Add ResponseSpec to WebClient
Replace the overloaded "retrieve" methods with a single retrieve() +
ResponseSpec exposing shortcut methods (bodyToMono, bodyToFlux)
mirroring the ClientResponse shortcuts it delegates to.

Unlike exchange() however with retrieve() there is no access to other
parts of ClientResponse so ResponseSpec exposes additional shortcuts
for obtain ResponseEntity<T> or ResponseEntity<List<T>>.

Issue: SPR-15294
2017-03-30 12:24:16 -04:00
Arjen Poutsma e6b4edc757 Simplify access to response body in WebClient
This commit makes a change to WebClient in oder to facilitate getting
the response body as a `Mono<Object>` or `Flux<Object>` without having
to deal with `ClientResponse`.

Specifically, this commit:

 - Adds `RequestHeaderSpec.retrieve` methods, next to `exchange`, that
 return the response body (and not a `ClientResponse`). Two convenience
 methods return the response body as `Mono` or `Flux`.
 - Adds ClientResponse.toRequestEntity to convert the ClientResponse
 into a RequestEntity.

Issue: SPR-15294
2017-03-30 08:58:04 -04:00
Sebastien Deleuze 9f321e8d56 Suppress warnings in tests 2017-03-30 14:28:10 +02:00
Sebastien Deleuze e2fd398bad Specify explicitly Kotlin extensions return type
The main purpose is to specify nullability.
2017-03-30 14:25:13 +02:00
Rossen Stoyanchev cd8c365a0d ServerCodecConfigurer as input in HandlerAdapter
The ServerCodecConfigurer is now passed all the way into the
RequestMappingHandlerAdapter which automatically enables the same
defaults even without the Java config and provides extra flexibility
in passing message codec configuration for the future.
2017-03-29 16:33:51 -04:00
Rossen Stoyanchev a8162c03f9 Add ArgumentResolverConfigurer
Replace the List<HandlerMethodArgumentResolver> with a dedicated
configurer that currently has one method accepting custom resolver
registrations.
2017-03-29 15:39:31 -04:00
Arjen Poutsma 118f33aeda Request body improvements in WebClient, WebTestClient
This commit makes changes to WebClient and WebTestClient in oder to
limit setting the body according to HTTP method and also to facilitate
providing the request body as Object.

Specifically, this commit:

 - Moves methods that operate on the request body to a RequestBodySpec
 in both WebClient and WebTestClient, and rename them to `body`.
 These methods now just *set* the body, without performing
 an exchange (which now requires an explicit exchange call).
 - Parameterizes UriSpec in both WebClient and WebTestClient, so that
 it returns either a RequestHeadersSpec or a RequestBodySpec.

Issue: SPR-15394
2017-03-29 12:22:15 -04:00
Rossen Stoyanchev c5bcefbd07 Complete RequestMappingHandlerAdapter refactoring
ControllerMethodResolver now also encapsulates initialization, storage,
and use of HandlerMethodArgumentResolver's by annotated method type.
2017-03-28 17:53:42 -04:00
Rossen Stoyanchev e06871ef17 Internal RequestMappingHandlerAdapter refactoring
Extract controller method caches including associated code and
discovery of @ControllerAdvice components into a separate, package
private helper class (ControllerMethodResolver).
2017-03-27 18:29:03 -04:00
Rossen Stoyanchev f8a21ab11b Add ClientCodecConfigurer
Issue: SPR-15247
2017-03-27 14:57:55 -04:00
Rossen Stoyanchev dc3851df00 Extract AbstractCodecConfigurer base class
Issue: SPR-15247
2017-03-27 14:57:49 -04:00
Sebastien Deleuze 3598addc0e Use FormHttpMessageReader by default in ServerCodecConfigurer 2017-03-26 03:21:05 +02:00
Rossen Stoyanchev 5414cd0cf8 Collape ServerHttpMessage[Reader|Writer]
This commit folds ServerHttpMessage[Reader|Writer] into its parent
HttpMessage[Reader|Writer] with the server methods pre-implemented
by default to be simple pass-through delegates.
2017-03-24 17:48:40 -04:00
Rossen Stoyanchev 4a7218f54f Introduce ServerCodecConfigurer
Issue: SPR-15247
2017-03-24 17:47:44 -04:00
Brian Clozel 2baceac5ff Resolve ResourceUrlProvider from current request
This commit changes `ResourceTransformerSupport` to look for the
`ResourceUrlProvider` in the current request if none is configured on
the resource transformer itself.

Issue: SPR-15369
2017-03-24 16:09:14 +01:00
Brian Clozel fdd503152d VersionResourceResolver should delegate to the chain
Prior to this commit, the `VersionResourceResolver` implementations of
`resolveUrlPathInternal` would delegate to the resolver chain but would
never use the give result if the current request didn't match a
configured version strategy pattern.

This is a problem if the resolver supposed to resolve the resource path
is configured after a `VersionResourceResolver` in the resolver chain;
this means that other resolver never gets to participate in the result
of the chain.

Issue: SPR-15372
2017-03-24 14:14:43 +01:00