Skip to content

Commit 5044bb6

Browse files
committed
refactor: http client
1 parent 9e1cab4 commit 5044bb6

22 files changed

+576
-671
lines changed

app/Auth/AccountGuard.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
use App\Helpers\CacheHelper;
1212
use App\Models\File;
13-
use Fresns\WebsiteEngine\Helpers\ApiHelper;
1413
use Fresns\WebsiteEngine\Helpers\DataHelper;
14+
use Fresns\WebsiteEngine\Helpers\HttpHelper;
1515
use GuzzleHttp\Exception\GuzzleException;
1616
use Illuminate\Auth\AuthenticationException;
1717
use Illuminate\Contracts\Foundation\Application;
@@ -136,7 +136,7 @@ public function get(?string $key = null): mixed
136136
$result = CacheHelper::get($cacheKey, $cacheTag);
137137

138138
if (empty($result)) {
139-
$result = ApiHelper::make()->get('/api/fresns/v1/account/detail');
139+
$result = HttpHelper::get('/api/fresns/v1/account/detail');
140140

141141
$cacheTime = CacheHelper::fresnsCacheTimeByFileType(File::TYPE_ALL);
142142
CacheHelper::put($result, $cacheKey, $cacheTag, $cacheTime);

app/Auth/UserGuard.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
use App\Helpers\CacheHelper;
1212
use App\Models\File;
13-
use Fresns\WebsiteEngine\Helpers\ApiHelper;
1413
use Fresns\WebsiteEngine\Helpers\DataHelper;
14+
use Fresns\WebsiteEngine\Helpers\HttpHelper;
1515
use GuzzleHttp\Exception\GuzzleException;
1616
use Illuminate\Auth\AuthenticationException;
1717
use Illuminate\Contracts\Foundation\Application;
@@ -135,7 +135,7 @@ public function get(?string $key = null): mixed
135135
$result = CacheHelper::get($cacheKey, $cacheTag);
136136

137137
if (empty($result)) {
138-
$result = ApiHelper::make()->get("/api/fresns/v1/user/{$uid}/detail");
138+
$result = HttpHelper::get("/api/fresns/v1/user/{$uid}/detail");
139139

140140
$cacheTime = CacheHelper::fresnsCacheTimeByFileType(File::TYPE_ALL);
141141
CacheHelper::put($result, $cacheKey, $cacheTag, $cacheTime);

app/Client/Clientable.php

Lines changed: 0 additions & 120 deletions
This file was deleted.

app/Exceptions/ErrorException.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ class ErrorException extends \Exception
1515
{
1616
public function render()
1717
{
18-
// dd($this->getCode(), $this->getMessage());
18+
if (request()->wantsJson()) {
19+
return \response()->json([
20+
'code' => $this->getCode(),
21+
'message' => $this->getMessage(),
22+
]);
23+
}
1924

2025
// set view
2126
$themeFskey = fs_theme('fskey');
@@ -31,13 +36,6 @@ public function render()
3136
View::getFinder()->setPaths($currentPaths);
3237
}
3338

34-
if (\request()->wantsJson()) {
35-
return \response()->json([
36-
'code' => $this->getCode(),
37-
'message' => $this->getMessage(),
38-
]);
39-
}
40-
4139
// 403 Forbidden
4240
if (in_array($this->getCode(), [
4341
36201, 37101, 37201, 37301, 37401, 37501,

app/Helpers/ApiHelper.php

Lines changed: 0 additions & 203 deletions
This file was deleted.

0 commit comments

Comments
 (0)