Skip to content

Commit

Permalink
Merge pull request #592 from LukasKnuth/patch-1
Browse files Browse the repository at this point in the history
Explained middleware ordering
  • Loading branch information
yordis authored May 25, 2023
2 parents e7c4371 + f3d0c4c commit 9fbf221
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/tesla/middleware.ex
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ defmodule Tesla.Middleware do
or inside tuple in case of dynamic middleware (`Tesla.client/1`):
Tesla.client([{Tesla.Middleware.BaseUrl, "https://example.com"}])
## Ordering
The order in which middleware is defined matters. Note that the order when _sending_ the request
matches the order the middleware was defined in, but the order when _receiving_ the response
is reversed.
For example, `Tesla.Middleware.DecompressResponse` must come _after_ `Tesla.Middleware.JSON`,
otherwise the response isn't decompressed before it reaches the JSON parser.
## Writing custom middleware
Expand Down

0 comments on commit 9fbf221

Please sign in to comment.