外部へのHTTPリクエストに独自のUser-Agentを付与する

This commit is contained in:
shibafu 2020-06-02 22:20:26 +09:00
parent da8af95043
commit 4c04deb80f

View File

@ -3,6 +3,8 @@
namespace App\Providers; namespace App\Providers;
use App\MetadataResolver\MetadataResolver; use App\MetadataResolver\MetadataResolver;
use GuzzleHttp\Client;
use GuzzleHttp\RequestOptions;
use Illuminate\Support\Facades\Blade; use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
use Parsedown; use Parsedown;
@ -36,5 +38,12 @@ class AppServiceProvider extends ServiceProvider
$this->app->singleton('parsedown', function () { $this->app->singleton('parsedown', function () {
return Parsedown::instance(); return Parsedown::instance();
}); });
$this->app->bind(Client::class, function () {
return new Client([
RequestOptions::HEADERS => [
'User-Agent' => 'TissueBot/1.0'
]
]);
});
} }
} }