Skip to content

Commit 7822860

Browse files
Remove prepared request guidance
Assisted-By: devx/1b826335-8b80-44c3-895e-60cc3d688770
1 parent 7796f55 commit 7822860

1 file changed

Lines changed: 2 additions & 35 deletions

File tree

guides/choosing-a-client/readme.md

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Choosing a Client
22

3-
This guide explains how to choose between ruby:`Async::HTTP::Internet`, ruby:`Async::HTTP::Client`, direct ruby:`Protocol::HTTP::Request` handling, and higher-level interfaces for libraries.
3+
This guide explains how to choose between ruby:`Async::HTTP::Internet`, ruby:`Async::HTTP::Client`, and higher-level interfaces for libraries.
44

5-
ruby:`Async::HTTP::Internet`, ruby:`Async::HTTP::Client`, and `Protocol::HTTP` middleware use the same request and response model. The important differences are how destinations are selected, where connection settings are applied, and who owns the client life cycle.
5+
ruby:`Async::HTTP::Internet` and ruby:`Async::HTTP::Client` use the same request and response model. The important differences are how destinations are selected, where connection settings are applied, and who owns the client life cycle.
66

77
## Quick Decision
88

@@ -11,7 +11,6 @@ ruby:`Async::HTTP::Internet`, ruby:`Async::HTTP::Client`, and `Protocol::HTTP` m
1111
| Requests may target different origins and the defaults are suitable. | Shared ruby:`Async::HTTP::Internet` | Selects and reuses a client for each origin automatically. |
1212
| Requests may target different origins, but need common client options or explicit ownership. | Explicit ruby:`Async::HTTP::Internet` | Applies the same options to each managed client and can be injected or closed early. |
1313
| Requests repeatedly target one configured origin. | ruby:`Async::HTTP::Client` | Exposes the endpoint, protocol, retry, and connection-pool configuration directly. |
14-
| A request is constructed separately or passed through middleware. | ruby:`Protocol::HTTP::Request` with `call` | Preserves the complete HTTP message across integration boundaries. |
1514
| A library wraps one HTTP service directly. | Injected ruby:`Async::HTTP::Client` or `Protocol::HTTP` middleware | Leaves transport configuration, ownership, and testing under application control. |
1615
| A library models an HTTP API as resources and representations. | [`async-rest`](https://socketry.github.io/async-rest/guides/getting-started/) | Provides higher-level API modeling over an injectable `Protocol::HTTP` delegate. |
1716
| A library uses Faraday as its HTTP abstraction. | [`async-http-faraday`](https://socketry.github.io/async-http-faraday/guides/getting-started/) | Lets the application retain the Faraday interface while using `Async::HTTP` as the transport. |
@@ -163,35 +162,3 @@ end
163162

164163
puts StatusService.new(connection).healthy?
165164
~~~
166-
167-
## Prepared Requests and Middleware
168-
169-
A ruby:`Protocol::HTTP::Request` is not another connection-management strategy. It is the complete HTTP message accepted by ruby:`Async::HTTP::Client#call` and by `Protocol::HTTP` middleware:
170-
171-
~~~ ruby
172-
require "async/http"
173-
174-
endpoint = Async::HTTP::Endpoint.parse("https://httpbin.org")
175-
176-
Sync do
177-
Async::HTTP::Client.open(endpoint) do |client|
178-
request = Protocol::HTTP::Request[
179-
"POST",
180-
"/anything",
181-
{"content-type" => "application/json"},
182-
'{"task":"refresh"}',
183-
]
184-
response = client.call(request)
185-
186-
begin
187-
puts response.status
188-
ensure
189-
response.close
190-
end
191-
end
192-
end
193-
~~~
194-
195-
Construct requests directly when another component produces the message, when using middleware, or when sending a custom HTTP method without a convenience method. The client still determines the endpoint and manages the connections.
196-
197-
For direct, in-process middleware tests, see the [Testing guide](../testing/). For the complete message interface, see the [`protocol-http` Getting Started guide](https://socketry.github.io/protocol-http/guides/getting-started/).

0 commit comments

Comments
 (0)