Commit Graph

507 Commits

Author SHA1 Message Date
Rossen Stoyanchev c1086f4114 Polish BindingContext
In preparation for SPR-15132.
2017-03-01 18:08:41 -05:00
Juergen Hoeller 2b3fb2f5cc Polishing 2017-02-28 18:37:33 +01:00
Arjen Poutsma 56d669f849 Add permanent/temporary redirect to ServerResponse
This commit adds the temporaryRedirect(URI) and permanentRedirect(URI)
static creation methods to ServerResponse.
2017-02-28 15:47:19 +01:00
Rossen Stoyanchev 5237e47e66 Polish 2017-02-27 17:26:20 -05:00
Rossen Stoyanchev 226c9f9a73 Add WebFlux redirect integration test case
Issue: SPR-15291
2017-02-27 17:14:56 -05:00
Sebastien Deleuze 40ae8d41a4 Introduce ServerResponse Kotlin extensions
Issue: SPR-15293
2017-02-27 19:46:07 +01:00
Sebastien Deleuze 710702acdc Polish Kotlin routing DSL
- typealias to replace types like RouterDsl.() -> Unit by Routes
 - String.invoke() as path("/foo") shortcut
 - String.route() as pathPrefix("/foo").route() shortcut
 - Avoid requiring PathPredicates.* import

Issue: SPR-15292
2017-02-27 19:14:24 +01:00
stonio 7d062df992 Use String#isEmpty()
Closes gh-1335
2017-02-22 11:55:17 +01:00
Juergen Hoeller d2cc97af47 Polishing 2017-02-21 22:41:40 +01:00
Juergen Hoeller 6242e30539 Polishing 2017-02-21 15:27:21 +01:00
Arjen Poutsma 7582adc0bc Fix trailing slash in nested path
This commit adds a trailing slash to the nested path if the request path
also ends with a slash. For instance, given the request "/foo/bar/", and
nested path pattern "/foo/**", we expect the nested path to be “/bar/”,
not “/bar".
2017-02-21 13:46:27 +01:00
Juergen Hoeller 1ddf8ec625 Polishing 2017-02-21 00:04:08 +01:00
Juergen Hoeller 73493bc490 Revised imports in tests (org.jetbrains.annotations.NotNull etc) 2017-02-20 23:00:22 +01:00
Arjen Poutsma 4221a344dc Treat empty Accept header as "*/*"
This commit changes the `accept` RequestPredicate so that it treats an
empty `Accept` header as having the value `*/*`, as per the HTTP spec.
2017-02-20 15:40:24 +01:00
Arjen Poutsma 1efcf26559 Defer evaluation of right-hand route in composed route 2017-02-20 10:59:53 +01:00
Arjen Poutsma 9ab8bd046c Improved logging in functional web framework
This commit improves predicate and route logging in the functional web
framework.
2017-02-20 10:59:23 +01:00
Sebastien Deleuze 4d48fde795 Fix RequestPredicate.route() implementation
Issue: SPR-14954
2017-02-16 23:34:28 +01:00
Sebastien Deleuze 305f303d46 Rename RouterDsl to Routes 2017-02-16 17:23:06 +01:00
Sebastien Deleuze 03f34e24ca Add nested route support to Kotlin DSL
Issue: SPR-14954
2017-02-16 17:22:55 +01:00
Arjen Poutsma 0922943c12 Rename RouterFunctions.subroute() to nest()
This commit renames the `RouterFunctions.subroute()` method to `nest()`, to
better represent what it does.

Issue: SPR-14954
2017-02-16 14:12:25 +01:00
Arjen Poutsma 1d589eb639 Add pathPrefix predicate
Added the `pathPrefix` predicate that tests the start of the request
path against a given pattern.

Issue: SPR-14954
2017-02-16 10:17:04 +01:00
Arjen Poutsma 36db6b2753 Removed json(), html() and xml() predicates
Removed `json()`, `html()` and `xml()` from `RequestPredicates`, since
they were confusingly named and would also require a counterpart that
reads the request `Content-Type` instead of the `Accept` header.
2017-02-15 11:06:08 +01:00
Sebastien Deleuze 7dd0f358ed Avoid using callable reference to stay Kotlin 1.0 compatible 2017-02-14 23:52:58 +01:00
Arjen Poutsma bb9d3e1680 Renamed RouterFunction composition methods
Renamed `RouterFunction.andSame()` to `and()`, and `and()` to
`andOther()`. The reason for this change is that we can expect most
RouterFunctions to be parameterized over ServerResponse, and thus it
makes sense to use the shortest composition method (`and()`) for
composing router functions of the same type.

When a user composes different response types, such as composing a
`RouterFunction<RenderingResponse>` with an
`RouterFunction<EntityResponse<?>`, the `andOther` method is to be used,
but this is a less common scenario.
2017-02-14 15:51:57 +01:00
Arjen Poutsma fcaf42507a Synchronise PathPatternParser access
This commit adds a synchronized block around the PathPatternParser,
since it is not thread-safe.
2017-02-14 12:11:48 +01:00
Sebastien Deleuze f380ab9d90 Polish RouterFunctionExtensions
Issue: SPR-15065
2017-02-13 23:08:56 +01:00
Rossen Stoyanchev 6f68af6860 Uncomment test following fix in reactor-netty 2017-02-13 15:02:42 -05:00
Arjen Poutsma febed19bf4 Use PathPatternParser in function.server
Use new PathPatternParser instead of PathMatcher in
web.reactive.function.server.
2017-02-13 16:44:03 +01:00
Arjen Poutsma a31429be2b Add json, html, and xml RequestPredicates
Added RequestPredicate for JSON, HTML, and XML requests. All three tests
for their respective mime type in the Accept header, as well as checking
for a file extension.
2017-02-13 15:37:50 +01:00
Arjen Poutsma dff9b3b85c Expose BodyInserter in EntityResponse 2017-02-13 15:09:43 +01:00
Sebastien Deleuze ef550c43d6 Flush JSON stream after each element
Issue: SPR-15104
2017-02-13 14:20:19 +01:00
Arjen Poutsma 45770d73ed Remove parameterisation from ClientRequest
This commit removes the parameterisation from ClientRequest, similarly
to ServerResponse. Dropping the parameterisation facilitates a
ClientRequest.from method that also copies the body of the target
request.

SPR-15234 Work in Progress
2017-02-13 13:54:23 +01:00
Brian Clozel 1901cc65fd Use ParsingPathMatcher by default in WebFlux
Issue:
2017-02-10 18:30:28 +01:00
Brian Clozel fa4202f1bd Revert Path Pattern changes in WebFlux
Issue: SPR-14544
2017-02-10 18:30:01 +01:00
Juergen Hoeller e9019cd7d1 Polishing 2017-02-10 10:56:40 +01:00
Brian Clozel 8d43f45515 Reduce API Surface in PathPatternRegistry
This commit reduces the exposition of `PathPattern` instances throughout
the `HandlerMapping` API and removes some methods from its public API.

Issue: SPR-14544
2017-02-09 22:09:46 +01:00
Arjen Poutsma 6dd0e6bfac Reverse "Correct generic type in BodyExtractor for form data"
This commit reverses 9efa976d31, and adds
code comments to highlight why some Body[Inserter|Extractor] instances
returned from Body[Inserters|Extractors] use
ServerHttp[Request|Response] instead of using
Reactive[Input|Output]Message.
2017-02-09 17:23:20 +01:00
Arjen Poutsma 11efbaead9 Ignore JsonStreamingIntegrationTests
Ignoring JsonStreamingIntegrationTests for now, @sdeleuze is aware of the need to fix.
2017-02-09 16:43:12 +01:00
Brian Clozel 09d18f2ef5 Refactor HandlerMapping path match configuration
Since the introduction of `PathPatternRegistry`, the various path match
configuration flags are no longer needed in several places and that
configuration can live in the registry itself.

Issue: SPR-14544
2017-02-09 15:58:16 +01:00
Arjen Poutsma da4af6157e Added ClientResponse.cookies()
Added cookies() method on ClientResponse, that exposes the response
cookies.

Issue: SPR-15236
2017-02-09 15:04:07 +01:00
Arjen Poutsma 2a512d7b9f Introduce EntityResponse
This commit introduces the EntityResponse, an entity-specific subtype of
ServerResponse that exposes the entity itself.
2017-02-09 13:46:00 +01:00
Brian Clozel 18c04815a7 Add PathPatternRegistry
This commit adds the new `PathPatternRegistry`, which  holds a
sorted set of `PathPattern`s and allows for searching/adding patterns

This registry is being used in `HandlerMapping` implementations and
separates path pattern parsing/matching logic from the rest. Directly
using `PathPattern` instances should improve the performance of those
`HandlerMapping` implementations, since the parsing and generation of
pattern variants (trailing slash, suffix patterns, etc) is done only
once.

Issue: SPR-14544
2017-02-09 11:21:33 +01:00
Andy Clement f58ffad939 Introduce PathPatternParser for optimized path matching
This commit introduces a PathPatternParser which parses request pattern
strings into PathPattern objects which can then be used to fast
match incoming string paths. The parser and matching supports the syntax
as described in SPR-14544. The code is optimized around the common usages
of request patterns and is designed to create very little transient
garbage when matching.

Issue: SPR-14544
2017-02-09 11:09:38 +01:00
Brian Clozel 6f029392c7 Move response status processing in InvocableHandlerMethod
Prior to this commit, WebFlux would look at the handler method
annotations (`@ResponseStatus`) for each handler execution, even calling
the expensive `synthesizeAnnotation`.

This commit moves this logic to the InvocableHandlerMethod so that this
executed once at instantiation time and for all result handlers.

Issue: SPR-15227
2017-02-09 10:30:02 +01:00
Rossen Stoyanchev 9efa976d31 Correct generic type in BodyExtractor for form data 2017-02-08 16:46:58 -05:00
Rossen Stoyanchev f2967467e0 Improve writing in mock reactive request and response
Before this change the write Publisher was saved and Mono.empty()
returned from the write metohd which did not properly implement
the write contract since no writing ("consuming") was done.

This can be a problem in some cases. For example the request may appear
to succeed even if the publisher produces an error later when
subscribed to later after request handling completes.

This commit introduces a writeHandler function in the mock request and
response. By default it "writes" by consuming the content immediately,
which allows it to return a Mono<Void> that properly reflects when
writing is done, and it also caches the data so it may be replayed
later for test assertions.

For streaming scenario a custom writeHandler may be registered which
allows the custom handling to determine how long to stream before
cancelling so request handling may complete.

Issue: SPR-14590
2017-02-07 21:57:38 -05:00
Sebastien Deleuze fe05d35292 Polish SseIntegrationTests 2017-02-06 18:24:55 +01:00
Sebastien Deleuze 6b9b0230c4 Introduce JSON streaming support
This commit introduces JSON streaming support which
consists of serializing HTTP request with
application/stream+json media type as line delimited JSON.

It also optimize Flux serialization for application/json by
using flux.collectList() and a single Jackson invocation
instead of one call per element previous strategy.
This change result in a x4 throughput improvement
for collection with a lot of small elements.

Issues: SPR-15095, SPR-15104
2017-02-06 18:14:53 +01:00
Arjen Poutsma 7796c4db14 Introduce RenderingResponse
This commit introduces the RenderingResponse, a template
rendering-specific subtype of ServerResponse that exposes model and
template data.
2017-02-03 11:25:48 +01:00
Eitan Adler 59bba3763d Polish javadoc
Closes gh-1311
2017-02-03 07:36:53 +01:00
Sebastien Deleuze 02c4aff4ce Upgrade to Kotlin 1.1.0-beta-38 2017-02-03 00:33:04 +01:00
Rossen Stoyanchev 1466c82f53 Better support for overriding base URI in WebClient
The base URI is ignored for requests that include a host.

WebClient exposes UriBuilder (rather than UriBuilderFactory) for
per-request URI building based on the base URI. That provides
full control to add or replace components of the base URI.
2017-02-02 17:24:18 -05:00
Rossen Stoyanchev 82a34f4b24 Update WebClient builder
Leave only one static, no-arg build() method for access to a Builder.

URI-related preferences are now exposed on the builder itself.

Improve Javadoc with base URI examples.
2017-02-02 17:17:37 -05:00
Rossen Stoyanchev 7399956708 Rename classes and methods containing "WebReactive"
Issue: SPR-15190
2017-02-02 11:25:54 -05:00
Sebastien Deleuze 123ee5f2da Add WebClient create() and build() static methods 2017-02-02 11:36:45 +01:00
Rossen Stoyanchev 080a3d6a41 Replace use of "Spring MVC" in spring-webflux module
Issue: SPR-15190
2017-02-01 17:50:24 -05:00
Rossen Stoyanchev fafd2d20e1 Rename spring-web-reactive to spring-webflux
Issue: SPR-15190
2017-02-01 17:02:52 -05:00