Skip to content

Conversation

@soul022
Copy link
Contributor

@soul022 soul022 commented Dec 30, 2025

Summary

This PR addresses #1590 by re-exporting the internal types that compose the HttpClient generic stack.

Currently, when a user applies middleware using HttpClientBuilder, the resulting type becomes a complex chain, such as HttpClient<MyMiddleware<RpcService<HttpBackend>>>. While some of these structs were marked pub, they were located in private modules, making it impossible for users to explicitly name the type in function signatures or struct definitions.

Example Usage

Before this change, the following code would fail to compile because RpcLogger, RpcService, and HttpBackend were not reachable:

use jsonrpsee::http_client::{HttpClient, RpcService, HttpBackend, RpcLogger, RpcServiceBuilder};

// Explicitly naming the default client type
fn get_client() -> HttpClient<RpcLogger<RpcService<HttpBackend>>> {
    HttpClient::builder()
        .build("http://localhost:9933")
        .unwrap()
}

// Naming a client with stripped/custom middleware
fn get_custom_client() -> HttpClient<RpcService<HttpBackend>> {
    HttpClient::builder()
        .set_rpc_middleware(RpcServiceBuilder::new())
        .build("http://localhost:9933")
        .unwrap()
}

Fixes

Closes #1590

@soul022 soul022 requested a review from a team as a code owner December 30, 2025 19:29
…ware

Re-exports RpcService, HttpBackend, HttpTransportClient, RpcLogger, RpcLoggerLayer,
RpcServiceBuilder, and RpcServiceT at the crate root so users can name the
HttpClient type when middleware is applied.

Also enables serde/alloc feature across workspace crates for no-default-features
compatibility, and updates trybuild stderr fixtures for rustc 1.92.0.

Closes #1590
@soul022 soul022 force-pushed the fix/http-client-private-types-1590 branch 3 times, most recently from ef1cff4 to 1a24191 Compare December 31, 2025 12:06
jsonrpsee-core = { workspace = true, features = ["client", "http-helpers"] }
rustls = { workspace = true, optional = true, features = ["logging", "std", "tls12", "ring"] }
rustls-platform-verifier = { workspace = true, optional = true }
serde = { workspace = true }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you remember why you added this feature everywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I added serde/alloc because cargo hack CI runs with --no-default-features, and without it jsonrpsee-types fails to compile - serde's Cow and Box impls require the alloc feature when std isn't enabled. this was a latent issue that this PR's CI exposed.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok sounds fair to me; I wonder why it came up now and not before hand.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is probably because cargo hack is exercising --no-default-features + async-client (and other combos) that don’t get hit in the usual workspace test run. Also, CI is on rustc 1.92.0 now, which changes diagnostics formatting, so a few try build fixtures needed refresh

@jsdw jsdw merged commit 22198bb into master Jan 15, 2026
18 checks passed
@jsdw jsdw deleted the fix/http-client-private-types-1590 branch January 15, 2026 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can't add middleware for HttpClientBuilder -> HttpClient generic has private struct inside that can't be used as return arg or propery type.

3 participants