Merge pull request #367 from shikorism/feature/user-agent

外部へのHTTPリクエストに独自のUser-Agentを付与する
This commit is contained in:
shibafu 2020-06-02 22:51:43 +09:00 committed by GitHub
commit 83b0ccf770
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View File

@ -26,6 +26,10 @@ commands:
- run: sudo apt install -y libpq-dev - run: sudo apt install -y libpq-dev
- run: sudo docker-php-ext-install zip - run: sudo docker-php-ext-install zip
- run: sudo docker-php-ext-install pdo_pgsql - run: sudo docker-php-ext-install pdo_pgsql
- run:
command: |
curl -sSL "https://nodejs.org/dist/v12.16.3/node-v12.16.3-linux-x64.tar.xz" | sudo tar --strip-components=2 -xJ -C /usr/local/bin/ node-v12.16.3-linux-x64/bin/node
curl https://www.npmjs.com/install.sh | sudo bash
restore_composer: restore_composer:
steps: steps:
- restore_cache: - restore_cache:

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'
]
]);
});
} }
} }