refactor(github): enhance API request handling and validation
- Updated validation rules for 'custom_user' and 'custom_port' fields to be nullable in the GithubController. - Refactored API request handling in GithubController, GithubPrivateRepository, and helper functions to use a consistent Http::GitHub method with timeout and retry logic. - Improved error handling for repository and branch loading processes.
This commit is contained in:
@@ -143,7 +143,13 @@ class GithubPrivateRepository extends Component
|
||||
|
||||
protected function loadBranchByPage()
|
||||
{
|
||||
$response = Http::withToken($this->token)->get("{$this->github_app->api_url}/repos/{$this->selected_repository_owner}/{$this->selected_repository_repo}/branches?per_page=100&page={$this->page}");
|
||||
$response = Http::GitHub($this->github_app->api_url, $this->token)
|
||||
->timeout(20)
|
||||
->retry(3, 200, throw: false)
|
||||
->get("/repos/{$this->selected_repository_owner}/{$this->selected_repository_repo}/branches", [
|
||||
'per_page' => 100,
|
||||
'page' => $this->page,
|
||||
]);
|
||||
$json = $response->json();
|
||||
if ($response->status() !== 200) {
|
||||
return $this->dispatch('error', $json['message']);
|
||||
|
Reference in New Issue
Block a user