Provides bridge to laravel framework HTTP components
drewlabs/laravel-http is a Laravel package for provides bridge to laravel framework http components.
It currently has 0 GitHub stars and 396 downloads on Packagist (latest version v0.4.1).
Install it with composer require drewlabs/laravel-http.
Discover more Laravel packages by drewlabs
or browse all Laravel packages to compare alternatives.
Last updated
The drewlabs/http package provides utility classes and functions for unified HTTP response API and middleware classes for handling CORS.
By default providers are automatically registered when running Laravel application after composer finishes installing the package.
// bootstrap/app.php
// ...
// Register the HttpService provider
$app->register(Drewlabs\Laravel\Http\HttpServiceProvider::class);
// ...
To use the cors middleware in your application add the following code to your kernel based on the framework being used:
// app/Http/Kernel.php
// ...
protected $middleware = [
// ...
\Drewlabs\Laravel\Http\Middleware\Cors::class,
];
// bootstrap/app.php
$app->middleware([
// Other globally registered middlewares...
\Drewlabs\Laravel\Http\Middleware\Cors::class,
]);
// ...
Note In order to allow any host or method, or headers use the * in the matching key of the config array.
It's a midleware that convert all empty string query parameteres and empty request body entry to null.
Note: Laravel already provide implementation for such case. But if you still want to use the current package middleware do it as follow.
// app/Http/Kernel.php
// ...
protected $middleware = [
// ...
\Drewlabs\Laravel\Http\Middleware\EmptyStringToNull::class,
];
// bootstrap/app.php
$app->middleware([
// Other globally registered middlewares...
\Drewlabs\Laravel\Http\Middleware\EmptyStringToNull::class,
]);
// ...
This configuration file contains middleware aliases keys definition for the application Http request handlers, like auth, policy middlewares.
php artisan vendor:publish --tag="drewlabs-http"