Repository navigation
v26.6.28
A Spring Boot parity increment: the declarative HTTP-interface client — the
highest single value lever from the parity-gap analysis (it lifts the REST/HTTP
clients area off the floor).
Added
#[http_client]— a declarative HTTP-interface client, the analog of
Spring 6's@HttpExchange(the modern OpenFeign replacement). Annotate a
trait of methods with the same verb attributes a#[rest_controller]
uses and the macro generates a<Trait>Implthat issues the requests over a
WebClient— the mirror image of a controller.- Verbs:
#[get("/path")]/#[post]/#[put]/#[delete]/
#[patch]+ generic#[request(method = "…")]. Path variables use the
framework's:idsyntax (same as the server macro);{id}is a compile
error pointing at:id. - Argument binding needs no attributes in the common case: a name-matched
:vararg is the path variable, the lone non-scalar arg on a body verb is
the JSON body, the rest are query params (Optionomits whenNone,
Vec/&[_]repeat). Override with#[path]/#[query("k")]/
#[header("X")]/#[body]. Every:varmust bind exactly once or it is a
compile error; anOption/Vec/slice path variable is rejected. - Return shapes:
async fn -> Result<T, ClientError>(the ergonomic
default),Result<T, E: From<ClientError>>, non-asyncMono<T>/Flux<T>
(returned directly; aFluxdefaultsAccept: application/x-ndjson), and
WebClientResponse(the.exchange()escape hatch). - Construction:
<Trait>Impl::new(base_url)or::with_client(WebClient);
the type isClone. With#[http_client(... bean)]it is registered as a
@Serviceand bound todyn Trait, so#[autowired] Arc<dyn Trait>
resolves (pulling a sharedWebClientbean, named viaclient = "…"). - Error fidelity (documented): an awaited
Result<T, ClientError>
surfaces every failure asClientError::Problem(carrying aFireflyError
with the original status/code, so the classifiers still work); the
structuredTransport/Decode/Encode/InvalidUrlvariants survive only
on theMono/Fluxreturn forms.
- Verbs:
firefly_client::encode_path_segment— RFC 3986 path-segment
percent-encoding (used by generated clients; also public).
The macro reuses the server #[rest_controller]'s verb-attribute grammar
(MappingAttr/VERBS/join_path), so client and server can't drift. Designed
via a scored 3-proposal panel and adversarially reviewed (the review caught a
runtime footgun — an Option path variable producing …/Some(x) URLs — now a
compile error). The firefly::prelude now also re-exports WebClient /
ClientError / new_web_client.