Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typos and improve language #705

Merged
merged 4 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/tesla.ex
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ defmodule Tesla do
@doc """
Adds given key/value pair to `:opts` field in `Tesla.Env`.

Useful when there's need to store additional middleware data in `Tesla.Env`
Useful when there's a need to store additional middleware data in `Tesla.Env`

## Examples

Expand Down
1 change: 1 addition & 0 deletions lib/tesla/adapter/mint.ex
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ if Code.ensure_loaded?(Mint.HTTP) do

{:error, _conn, error, _res} ->
if opts[:close_conn], do: {:ok, _conn} = close(conn)
# TODO: (breaking change) fix typo in error message, "Encounter" => "Encountered"
{:error, "Encounter Mint error #{inspect(error)}"}

:unknown ->
Expand Down
2 changes: 1 addition & 1 deletion lib/tesla/builder.ex
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ defmodule Tesla.Builder do
- `:method` - the request method, one of [`:head`, `:get`, `:delete`, `:trace`, `:options`, `:post`, `:put`, `:patch`]
- `:url` - either full url e.g. "http://example.com/some/path" or just "/some/path" if using `Tesla.Middleware.BaseUrl`
- `:query` - a keyword list of query params, e.g. `[page: 1, per_page: 100]`
- `:headers` - a keyworld list of headers, e.g. `[{"content-type", "text/plain"}]`
- `:headers` - a keyword list of headers, e.g. `[{"content-type", "text/plain"}]`
- `:body` - depends on used middleware:
- by default it can be a binary
- if using e.g. JSON encoding middleware it can be a nested map
Expand Down
2 changes: 1 addition & 1 deletion lib/tesla/middleware/form_urlencoded.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defmodule Tesla.Middleware.FormUrlencoded do
Send request body as `application/x-www-form-urlencoded`.

Performs encoding of `body` from a `Map` such as `%{"foo" => "bar"}` into
url encoded data.
URL-encoded data.

Performs decoding of the response into a map when urlencoded and content-type
is `application/x-www-form-urlencoded`, so `"foo=bar"` becomes
Expand Down
4 changes: 2 additions & 2 deletions lib/tesla/middleware/keep_request.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
defmodule Tesla.Middleware.KeepRequest do
@moduledoc """
Store request url, body and headers into `:opts`.
Store request URL, body, and headers into `:opts`.

## Examples

Expand All @@ -12,7 +12,7 @@ defmodule Tesla.Middleware.KeepRequest do
plug Tesla.Middleware.PathParams
end

{:ok, env} = MyClient.post("/users/:user_id", "request-data", opts: [path_params: [user_id: "1234]])
{:ok, env} = MyClient.post("/users/:user_id", "request-data", opts: [path_params: [user_id: "1234"]])

env.body
# => "response-data"
Expand Down
8 changes: 4 additions & 4 deletions lib/tesla/middleware/telemetry.ex
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,19 @@ if Code.ensure_loaded?(:telemetry) do
This event can be disabled by setting `config :tesla, Tesla.Middleware.Telemetry, disable_legacy_event: true` in your config.
Be sure to run `mix deps.compile --force tesla` after changing this setting to ensure the change is picked up.

Please check the [telemetry](https://hexdocs.pm/telemetry/) for the further usage.
Please check the [telemetry](https://hexdocs.pm/telemetry/) for further usage.

## URL event scoping with `Tesla.Middleware.PathParams` and `Tesla.Middleware.KeepRequest`

Sometimes, it is useful to have access to a template url (i.e. `"/users/:user_id"`) for grouping
Sometimes, it is useful to have access to a template URL (i.e. `"/users/:user_id"`) for grouping
Telemetry events. For such cases, a combination of the `Tesla.Middleware.PathParams`,
`Tesla.Middleware.Telemetry` and `Tesla.Middleware.KeepRequest` may be used.

```
defmodule MyClient do
use Tesla

# The KeepRequest middleware sets the template url as a Tesla.Env.opts entry
# The KeepRequest middleware sets the template URL as a Tesla.Env.opts entry
# Said entry must be used because on happy-path scenarios,
# the Telemetry middleware will receive the Tesla.Env.url resolved by PathParams.
plug Tesla.Middleware.KeepRequest
Expand All @@ -72,7 +72,7 @@ if Code.ensure_loaded?(:telemetry) do
fn event, measurements, meta, config ->
path_params_template_url = meta.env.opts[:req_url]
# The meta.env.url key will only present the resolved URL on happy-path scenarios.
# Error cases will still return the original template url.
# Error cases will still return the original template URL.
path_params_resolved_url = meta.env.url
end,
nil
Expand Down
2 changes: 1 addition & 1 deletion lib/tesla/middleware/timeout.ex
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ defmodule Tesla.Middleware.Timeout do

- `:timeout` - number of milliseconds a request is allowed to take (defaults to `1000`)
- `:task_module` - the `Task` module used to spawn tasks. Useful when you want
use alternatives such as `OpentelemetryProcessPropagator.Task` from OTEL
to use alternatives such as `OpentelemetryProcessPropagator.Task` from the OTEL
project.
"""

Expand Down
2 changes: 1 addition & 1 deletion lib/tesla/multipart.ex
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ defmodule Tesla.Multipart do
@doc """
Add a file part with value.

Same of `add_file/3` but the file content is read from `data` input argument.
Same as `add_file/3` but the file content is read from `data` input argument.

## Options

Expand Down
2 changes: 1 addition & 1 deletion test/tesla/middleware/digest_auth_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ defmodule Tesla.Middleware.DigestAuthTest do
assert auth_header =~ "response=\"6629fae49393a05397450978507c4ef1\""
end

test "has default values for username and cn" do
test "has default values for username and nc" do
assert {:ok, response} = DigestClientWithDefaults.client() |> DigestClient.get("/")
auth_header = Tesla.get_header(response, "authorization")

Expand Down
2 changes: 1 addition & 1 deletion test/tesla/middleware/json_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ defmodule Tesla.Middleware.JsonTest do
assert {:error, {Tesla.Middleware.JSON, :decode, _}} = Client.get("/invalid-json-format")
end

test "raise error when decoding non-utf8 json" do
test "return error when decoding non-utf8 json" do
assert {:error, {Tesla.Middleware.JSON, :decode, _}} = Client.get("/invalid-json-encoding")
end
end
Expand Down
Loading