Skip to content

Commit

Permalink
fix broken HttpClient links (closes #447)
Browse files Browse the repository at this point in the history
also fix rama-macros/tests/macros non-workspace member bug
that can be seen via cargo hack
  • Loading branch information
GlenDC committed Mar 8, 2025
1 parent 0e31415 commit 88969d5
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 9 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ members = [
"rama-http-core/tests/h2-support",
"rama-http-types",
"rama-macros",
"rama-macros/tests/macros",
"rama-net",
"rama-proxy",
"rama-socks5",
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ In [The rama book](https://ramaproxy.org/book) you can read and learn that a big
It's a powerful concept, originally introduced to Rust by [the Tower ecosystem](https://github.com/tower-rs/tower) and allows you build complex stacks specialised to your needs in a modular and easy manner. Even cooler is that this works for both clients and servers alike.
Rama provides an [`HttpClient`](https://ramaproxy.org/docs/rama/http/client/struct.HttpClient.html) which sends your _Http_ `Request` over the network and returns the `Response` if it receives and read one or an `Error` otherwise. Combined with [the many Layers (middleware)](https://ramaproxy.org/docs/rama/http/layer/index.html) that `Rama` provides and perhaps also some developed by you it is possible to create a powerful _Http_ client suited to your needs.
Rama provides an [`EasyHttpWebClient`](https://ramaproxy.org/docs/rama/http/client/struct.EasyHttpWebClient.html) which sends your _Http_ `Request` over the network and returns the `Response` if it receives and read one or an `Error` otherwise. Combined with [the many Layers (middleware)](https://ramaproxy.org/docs/rama/http/layer/index.html) that `Rama` provides and perhaps also some developed by you it is possible to create a powerful _Http_ client suited to your needs.
As a 🍒 cherry on the cake you can import the [`HttpClientExt`](https://ramaproxy.org/docs/rama/http/service/client/trait.HttpClientExt.html) trait in your Rust module to be able to use your _Http_ Client [`Service`][rama-service] stack using a high level API to build and send requests with ease.
Expand All @@ -330,7 +330,7 @@ let client = (
RetryLayer::new(
ManagedPolicy::default().with_backoff(ExponentialBackoff::default()),
),
).layer(HttpClient::default());
).layer(EasyHttpWebClient::default());
#[derive(Debug, Deserialize)]
struct Info {
Expand Down
4 changes: 2 additions & 2 deletions docs/book/src/http_clients.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ In [The "🗼 Services all the way down 🐢" chapter](./intro/services_all_the_

It's a powerful concept, originally introduced to Rust by [the Tower ecosystem](https://github.com/tower-rs/tower) and allows you build complex stacks specialised to your needs in a modular and easy manner. Even cooler is that this works for both clients and servers alike.

Rama provides an [`HttpClient`](https://ramaproxy.org/docs/rama/http/client/struct.HttpClient.html) which sends your _Http_ `Request` over the network and returns the `Response` if it receives and read one or an `Error` otherwise. Combined with [the many Layers (middleware)](https://ramaproxy.org/docs/rama/http/layer/index.html) that `Rama` provides and perhaps also some developed by you it is possible to create a powerful _Http_ client suited to your needs.
Rama provides an [`EasyHttpWebClient`](https://ramaproxy.org/docs/rama/http/client/struct.EasyHttpWebClient.html) which sends your _Http_ `Request` over the network and returns the `Response` if it receives and read one or an `Error` otherwise. Combined with [the many Layers (middleware)](https://ramaproxy.org/docs/rama/http/layer/index.html) that `Rama` provides and perhaps also some developed by you it is possible to create a powerful _Http_ client suited to your needs.

As a 🍒 cherry on the cake you can import the [`HttpClientExt`](https://ramaproxy.org/docs/rama/http/service/client/trait.HttpClientExt.html) trait in your Rust module to be able to use your _Http_ Client [`Service`][rama-service] stack using a high level API to build and send requests with ease.

Expand All @@ -26,7 +26,7 @@ let client = (
RetryLayer::new(
ManagedPolicy::default().with_backoff(ExponentialBackoff::default()),
)
.layer(HttpClient::default());
.layer(EasyHttpWebClient::default());

#[derive(Debug, Deserialize)]
struct Info {
Expand Down
2 changes: 1 addition & 1 deletion docs/book/src/intro/service_branches.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ The match concept is pretty powerful, be it by using [the `Matcher` trait](https

Take a typical http client for example. As part of its work it needs to establish a connection to the target server. In the case of port `8080` this would be a plain `tcp` connection (for `http/1.1`), but in the case of port `443` that would require the `tcp` stream to be handled by a `Tls` client first (e.g. for `h2`).

Using the tuple matchers you can wrap these two different flows in a two-element tuple with a [`SocketMatcher`](https://ramaproxy.org/docs/rama/net/stream/matcher/struct.SocketMatcher.html) to match on the port (for example). And in fact that is more or less what [the HttpClient](https://ramaproxy.org/docs/rama/http/client/struct.HttpClient.html) does by default if you do not specify your own "Connection" service. We hope you can make happy use of it yourself.
Using the tuple matchers you can wrap these two different flows in a two-element tuple with a [`SocketMatcher`](https://ramaproxy.org/docs/rama/net/stream/matcher/struct.SocketMatcher.html) to match on the port (for example). And in fact that is more or less what [the EasyHttpWebClient](https://ramaproxy.org/docs/rama/http/client/struct.EasyHttpWebClient.html) does by default if you do not specify your own "Connection" service. We hope you can make happy use of it yourself.

## Fallible middleware services

Expand Down
2 changes: 1 addition & 1 deletion docs/book/src/intro/services_all_the_way_down.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ Within Rama pretty much anything is a service, except for the configurable parts

A notable difference from other (web) frameworks where you might have worked with the concept of services is that within Rama you can have services on multiple layers of the network stack. The lowest layer that we offer support for is the transport layer, allowing you to operate as a leaf or middleware service directly on the input Tcp/Udp stream. The highest layer is the Http layer which you are most likely already familiar with. Layers such as Tls operate within the transport layer for what is Rama concerned. As tls is from a minimal POV simply a wrapper around the Tcp stream.

The story doesn't end here however. Where in most frameworks you would also have "thick" services such as an Http client. This is not the case in Rama. Here we really do it services all the way down. If you look at Rama's [HttpClient](https://ramaproxy.org/docs/rama/http/client/struct.HttpClient.html) you'll notice that it takes optionally a service to get connections. This allows you to build any kind of service stack you wish, where the input is the http request, and out the output is the input + a connection to be operated upon. Features such as a connection pool are implemented in the form of layers that you can easily add to your `HttpClient` in that manner. As we said... services all the way down.
The story doesn't end here however. Where in most frameworks you would also have "thick" services such as an Http client. This is not the case in Rama. Here we really do it services all the way down. If you look at Rama's [EasyHttpWebClient](https://ramaproxy.org/docs/rama/http/client/struct.EasyHttpWebClient.html) you'll notice that it takes optionally a service to get connections. This allows you to build any kind of service stack you wish, where the input is the http request, and out the output is the input + a connection to be operated upon. Features such as a connection pool are implemented in the form of layers that you can easily add to your `EasyHttpWebClient` in that manner. As we said... services all the way down.
5 changes: 4 additions & 1 deletion rama-macros/tests/macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ authors = [
"David Tolnay <[email protected]>",
"Glen Henri J. De Cauwsemaecker <[email protected]>",
]
edition = "2021"
edition = "2024"
publish = false

[lint]
workspace = true

[lib]
path = "lib.rs"
proc-macro = true
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@
//!
//! It's a powerful concept, originally introduced to Rust by [the Tower ecosystem](https://github.com/tower-rs/tower) and allows you build complex stacks specialised to your needs in a modular and easy manner. Even cooler is that this works for both clients and servers alike.
//!
//! Rama provides an [`HttpClient`](https://ramaproxy.org/docs/rama/http/client/struct.HttpClient.html) which sends your _Http_ `Request` over the network and returns the `Response` if it receives and read one or an `Error` otherwise. Combined with [the many Layers (middleware)](https://ramaproxy.org/docs/rama/http/layer/index.html) that `Rama` provides and perhaps also some developed by you it is possible to create a powerful _Http_ client suited to your needs.
//! Rama provides an [`EasyHttpWebClient`](https://ramaproxy.org/docs/rama/http/client/struct.EasyHttpWebClient.html) which sends your _Http_ `Request` over the network and returns the `Response` if it receives and read one or an `Error` otherwise. Combined with [the many Layers (middleware)](https://ramaproxy.org/docs/rama/http/layer/index.html) that `Rama` provides and perhaps also some developed by you it is possible to create a powerful _Http_ client suited to your needs.
//!
//! As a 🍒 cherry on the cake you can import the [`HttpClientExt`](https://ramaproxy.org/docs/rama/http/service/client/trait.HttpClientExt.html) trait in your Rust module to be able to use your _Http_ Client [`Service`][rama-service] stack using a high level API to build and send requests with ease.
//!
Expand All @@ -289,7 +289,7 @@
//! RetryLayer::new(
//! ManagedPolicy::default().with_backoff(ExponentialBackoff::default()),
//! ),
//! ).layer(HttpClient::default());
//! ).layer(EasyHttpWebClient::default());
//!
//! #[derive(Debug, Deserialize)]
//! struct Info {
Expand Down

0 comments on commit 88969d5

Please sign in to comment.