Parse optional trailing query parameters off subjects (#49)#52
Merged
Conversation
AntPatternNamespace had no notion of an optional trailing query string,
which (a) polluted the last path variable when a subject carried a
`?query`, and (b) left consumers no way to read query parameters.
util:
- Strip an optional trailing `?query` before match/extractPathVariables
so path variables are never polluted (fixes the bug).
- Add extractQueryParameters(subject): parses `?a=b&c=d` into a map
(empty when absent), via a shared pure parseQueryString helper
(URL-decoding, empty values, last-wins on repeated keys).
- URL-decode path variables too, for consistency with the Spring
DataSourceMessageHandler which already decodes destination variables.
NOTE: this changes query-less subjects like /X/EUR%2FUSD to yield
EUR/USD instead of EUR%2FUSD.
- Expose a shared CHARSET constant; DataSourceServerBootstrap sources
its bootstrapCharset from it.
reactive DSL:
- Thread the parsed query map to all supplier shapes via a Request /
ChannelRequest object (path, pathVariables, queryParameters[, receive])
instead of positional params, avoiding the same-typed adjacent-map
footgun and making future additions non-breaking.
- RequestSupplier / ChannelRequestSupplier are receiver-style SAMs, so
Kotlin gets `{ this.path }` ergonomics with no overload ambiguity while
Java implements a clean `invoke(request)`.
- Retain the previous positional shapes as @deprecated PathVariablesSupplier
/ PathVariablesChannelSupplier overloads for source back-compat.
Public API: additive to util; the reactive supplier interfaces are
reshaped (deprecated overloads retained) — a major bump. .api snapshots
regenerated.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #49.
What & why
AntPatternNamespacehad no notion of an optional trailing query string on a subject, which (a) polluted the last path variable when a subject carried a?query, and (b) left consumers no way to read query parameters. This adds first-class parsing of an optional trailing?a=b&c=d.Changes
datasourcex-util?querybeforematch/extractPathVariablesso path variables are never polluted (the bug fix).extractQueryParameters(subject)— parses?a=b&c=dinto a map (empty when absent), via a shared pureparseQueryStringhelper (URL-decoding, empty values, last-wins on repeated keys).DataSourceMessageHandler(which already decodes destination variables).CHARSET;DataSourceServerBootstrap.bootstrapCharsetsources from it.Reactive Bind DSL
Request/ChannelRequestobject (path,pathVariables,queryParameters[,receive]) instead of positional params — avoids the adjacent same-typed-map footgun and makes future field additions non-breaking.RequestSupplier/ChannelRequestSupplierare receiver-style SAMs (operator fun Request.invoke()): Kotlin gets{ this.path }ergonomics from a single overload (no ambiguity), Java implements a cleaninvoke(request).@DeprecatedPathVariablesSupplier/PathVariablesChannelSupplieroverloads for source back-compat.Because path variables are now URL-decoded (matching the Spring handler):
+in a value becomes a space (e.g./RATES/USD+SOFR→USD SOFR).%(e.g.100%) throwsIllegalArgumentException.+/%is therefore no longer byte-identical to before.This was a deliberate call for consistency with the existing Spring destination-variable decoding.
Versioning
Additive to
datasourcex-util. The reactive supplier interfaces are reshaped (deprecated overloads retained) → major bump..apisnapshots regenerated.Testing
./gradlew --continue checkgreen.AntPatternNamespaceTestcovers pollution-fix, no/single/multiple query params, query on an exact pattern, path+query URL-decoding, empty values, and repeated keys;BindTestadds an end-to-end receiver-style + query-parameter delivery test.Spring note
Investigated whether Spring
@MessageMappingoffers query parameters — it does not (only@DestinationVariable/@Header/@Headers/@Payload/Principal; no@RequestParamequivalent for messaging destinations), so this is a genuine framework extension.