lanser/http-facade-middleware

middleware for Laravel http facade Request and Response options and parameters

dev-main 2023-02-19 19:19 UTC

This package is auto-updated.

Last update: 2025-02-20 00:17:26 UTC


README

INSTALL

composer require lanser/http-facade-middleware:dev-main

With GuzzleHttp Client

$stack = HandlerStack::create(new CurlHandler());

$stack->push(new ExampleGuzzleMiddleware());

$client = new Client([ 'base_uri' => 'https://dummyjson.com', 'handler' => $stack, ]);

$res = $client->get("/products/1");

With Laravel Http Facade

  Http::baseUrl('https://dummyjson.com')
    ->withHeaders([
        'Accept' => 'application/json',
        'Content-Type' => 'application/json',
    ])
    ->withMiddleware(new ExampleGuzzleMiddleware())
      ->get("/products/1")->json();