You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
List of changes:
- Bump license year
- Use common source url
- Fix typos
- Fix markdown
- Add release changelog to readme
- Add hexdocs badge
- Use and set ex_doc to latest version
- Update gitignore
-[`Tesla.Middleware.MethodOverride`](https://hexdocs.pm/tesla/Tesla.Middleware.MethodOverride.html) - set `X-Http-Method-Override` header
116
+
-[`Tesla.Middleware.Logger`](https://hexdocs.pm/tesla/Tesla.Middleware.Logger.html) - log requests (method, url, status, and time)
117
+
-[`Tesla.Middleware.KeepRequest`](https://hexdocs.pm/tesla/Tesla.Middleware.KeepRequest.html) - keep request `body` and `headers`
122
118
-[`Tesla.Middleware.PathParams`](https://hexdocs.pm/tesla/Tesla.Middleware.PathParams.html) - use templated URLs
123
119
124
120
### Formats
125
121
126
122
-[`Tesla.Middleware.FormUrlencoded`](https://hexdocs.pm/tesla/Tesla.Middleware.FormUrlencoded.html) - urlencode POST body, useful for POSTing a map/keyword list
127
123
-[`Tesla.Middleware.JSON`](https://hexdocs.pm/tesla/Tesla.Middleware.JSON.html) - JSON request/response body
-[`Tesla.Middleware.Compression`](https://hexdocs.pm/tesla/Tesla.Middleware.Compression.html) - `gzip` and `deflate`
129
125
-[`Tesla.Middleware.DecodeRels`](https://hexdocs.pm/tesla/Tesla.Middleware.DecodeRels.html) - decode `Link` header into `opts[:rels]` field in response
130
126
131
127
### Auth
@@ -141,7 +137,7 @@ This is very similar to how [Plug Router](https://github.com/elixir-plug/plug#th
141
137
142
138
## Runtime middleware
143
139
144
-
All HTTP functions (`get`, `post`, etc.) can take a dynamic client as the first argument.
140
+
All HTTP functions, such as `Tesla.get/3` and `Tesla.post/4`, can take a dynamic client as the first argument.
145
141
This allow to use convenient syntax for modifying the behaviour in runtime.
146
142
147
143
Consider the following case: GitHub API can be accessed using OAuth token authorization.
@@ -196,13 +192,14 @@ Tesla supports multiple HTTP adapter that do the actual HTTP request processing.
196
192
-[`Tesla.Adapter.Mint`](https://hexdocs.pm/tesla/Tesla.Adapter.Mint.html) - [mint](https://github.com/elixir-mint/mint), "Functional HTTP client for Elixir with support for HTTP/1 and HTTP/2"
197
193
-[`Tesla.Adapter.Finch`](https://hexdocs.pm/tesla/Tesla.Adapter.Finch.html) - [finch](https://github.com/keathley/finch), "An HTTP client with a focus on performance, built on top of [Mint](https://github.com/elixir-mint/mint) and [NimblePool](https://github.com/dashbitco/nimble_pool)."
198
194
199
-
When using adapter other than httpc remember to add it to the dependencies list in `mix.exs`
195
+
When using adapter other than `:httpc` remember to add it to the dependencies list in `mix.exs`
200
196
201
197
```elixir
202
198
defpdepsdo
203
-
[{:tesla, "~> 1.4.0"},
204
-
{:jason, ">= 1.0.0"}, # optional, required by JSON middleware
205
-
{:hackney, "~> 1.10"}] # or :gun etc.
199
+
[
200
+
{:tesla, "~> 1.4.0"},
201
+
{:hackney, "~> 1.10"} # when using hackney adapter
202
+
]
206
203
end
207
204
```
208
205
@@ -230,7 +227,7 @@ def new(...) do
230
227
end
231
228
```
232
229
233
-
Passing directly to `get`/`post`/etc.
230
+
Passing directly to request functions such as `MyClient.get/3` or `Tesla.get/3`.
Each piece of stream will be encoded as JSON and sent as a new line (conforming to JSON stream format)
255
+
Each piece of stream will be encoded as JSON and sent as a new line (conforming to JSON stream format).
259
256
260
257
## Multipart
261
258
262
-
You can pass a `Tesla.Multipart` struct as the body.
259
+
You can pass a `Tesla.Multipart` struct as the body:
263
260
264
261
```elixir
265
262
aliasTesla.Multipart
@@ -280,7 +277,7 @@ mp =
280
277
281
278
## Testing
282
279
283
-
You can set the adapter to `Tesla.Mock` in tests.
280
+
You can set the adapter to `Tesla.Mock` in tests:
284
281
285
282
```elixir
286
283
# config/test.exs
@@ -320,8 +317,7 @@ end
320
317
321
318
## Writing middleware
322
319
323
-
A Tesla middleware is a module with `c:Tesla.Middleware.call/3` function, that at some point calls `Tesla.run/2` with `env` and `next` to process
324
-
the rest of stack.
320
+
A Tesla middleware is a module with `c:Tesla.Middleware.call/3` function, that at some point calls `Tesla.run/2` with `env` and `next` to process the rest of stack.
325
321
326
322
```elixir
327
323
defmoduleMyMiddlewaredo
@@ -384,7 +380,7 @@ defmodule Tesla.Middleware.SomeMiddleware do
384
380
Longer description, including e.g. additional dependencies.
385
381
386
382
387
-
### Example usage
383
+
### Examples
388
384
389
385
```
390
386
defmodule MyClient do
@@ -503,6 +499,10 @@ defmodule Tesla.Middleware.MyCustomMiddleware do
503
499
end
504
500
```
505
501
502
+
## [`0.x` to `1.0` Migration Guide](https://github.com/teamon/tesla/wiki/0.x-to-1.0-Migration-Guide)
503
+
504
+
[Documentation for 0.x branch](https://github.com/teamon/tesla/tree/0.x)
505
+
506
506
## Contributing
507
507
508
508
1. Fork it (https://github.com/teamon/tesla/fork)
@@ -515,7 +515,7 @@ end
515
515
516
516
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details
0 commit comments