Skip to content

[HttpClient] Ability to add middlewares  #32367

@flaver12

Description

@flaver12

It would be nice to have the ability to add middlewares to the request.
I came up with this because I had the case that I use an API to get projects.
The API has a request limit, after that, it sends back a 429. In this case, it would be nice to have the ability to add a middleware that can react to that.
Or in other cases where if you have a certain header to do something with it before it comes to the actual logic.

<?php
$middlewares = Middlewares::create();
$middlewares->push($instanceOfMyMiddleware);
$this->client->request('GET', 'https://my-example-api.com/endpoint', ['middlewares' => $middlewares]);

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions