2022-08-12 07:56:56 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Providers;
|
|
|
|
|
2022-11-07 04:37:54 +00:00
|
|
|
use App\Models\PersonalAccessToken;
|
2022-11-14 10:37:09 +00:00
|
|
|
use Illuminate\Pagination\Paginator;
|
2022-08-19 09:51:52 +00:00
|
|
|
use Illuminate\Support\Facades\Http;
|
2022-10-29 05:53:32 +00:00
|
|
|
use Illuminate\Support\ServiceProvider;
|
2022-11-08 13:01:43 +00:00
|
|
|
use Laravel\Sanctum\Sanctum;
|
2022-10-30 02:29:59 +00:00
|
|
|
|
2022-08-12 07:56:56 +00:00
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Register any application services.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function register()
|
|
|
|
{
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
2022-11-06 11:28:22 +00:00
|
|
|
/**
|
|
|
|
* Bootstrap any application services.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2022-08-12 07:56:56 +00:00
|
|
|
public function boot()
|
|
|
|
{
|
|
|
|
//
|
2022-08-19 09:51:52 +00:00
|
|
|
|
2022-11-14 10:37:09 +00:00
|
|
|
Paginator::useBootstrapFive();
|
|
|
|
|
2022-11-07 04:37:54 +00:00
|
|
|
Sanctum::usePersonalAccessTokenModel(PersonalAccessToken::class);
|
|
|
|
|
2022-11-16 02:29:50 +00:00
|
|
|
Http::macro('module', function ($api_token, $url) {
|
2022-08-27 08:28:39 +00:00
|
|
|
// 关闭证书验证
|
|
|
|
return Http::withoutVerifying()->withHeaders([
|
2022-11-16 02:29:50 +00:00
|
|
|
'X-Module-Api-Token' => $api_token,
|
2022-11-16 02:44:55 +00:00
|
|
|
'Content-Type' => 'application/json',
|
|
|
|
'Accept' => 'application/json',
|
2022-10-04 10:34:23 +00:00
|
|
|
])->withOptions([
|
|
|
|
'version' => 2,
|
2022-08-19 09:51:52 +00:00
|
|
|
])->baseUrl($url);
|
|
|
|
});
|
2022-10-29 05:53:32 +00:00
|
|
|
}
|
2022-08-12 07:56:56 +00:00
|
|
|
}
|