Skip to content

Document middlewares order (priority) #1458

@AlexWayfer

Description

@AlexWayfer

Basic Info

  • Faraday Version: 2.6.0
  • Ruby Version: 3.1

Issue description

Please, add more documentation about middlewares ordering and priority. With detailed explanations how hooks work, I think.

Steps to reproduce

I had a code like:

Faraday.new(...) do |faraday|
  faraday.request :json
  faraday.response :json

  faraday.response :parse_dates
end

It seems obviously for me that a response firstly being decoded from JSON, then dates will be parsed.

The gem for parsing dates BTW: https://github.com/AlexWayfer/faraday-parse_dates

But it didn't work, until I've change their order.

Why? I believe I've done everything according to middlewares documentation in the faraday-parse_dates gem.

At the https://lostisland.github.io/faraday/middleware/ I've found such documentation:

Swapping middleware means giving the other priority.

How, in which order, some examples and strict rules?

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationinfoGeneric question on how to use Faraday

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions