2023-03-17 14:33:48 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Providers;
|
|
|
|
|
2023-05-30 13:52:17 +00:00
|
|
|
use Illuminate\Support\Facades\Http;
|
2023-03-17 14:33:48 +00:00
|
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
|
|
{
|
|
|
|
public function register(): void
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public function boot(): void
|
|
|
|
{
|
2023-06-13 13:01:11 +00:00
|
|
|
Http::macro('github', function (string $api_url, string|null $github_access_token = null) {
|
|
|
|
if ($github_access_token) {
|
|
|
|
return Http::withHeaders([
|
|
|
|
'X-GitHub-Api-Version' => '2022-11-28',
|
|
|
|
'Accept' => 'application/vnd.github.v3+json',
|
|
|
|
'Authorization' => "Bearer $github_access_token",
|
|
|
|
])->baseUrl($api_url);
|
|
|
|
} else {
|
|
|
|
return Http::withHeaders([
|
|
|
|
'Accept' => 'application/vnd.github.v3+json',
|
|
|
|
])->baseUrl($api_url);
|
|
|
|
}
|
2023-05-30 13:52:17 +00:00
|
|
|
});
|
2023-03-17 14:33:48 +00:00
|
|
|
}
|
|
|
|
}
|