mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-29 18:38:36 +08:00
List Repos: Print the http req as curl
Makes it easier to test
This commit is contained in:
@ -2,11 +2,13 @@ import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart' as foundation;
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import 'package:gitjournal/utils.dart';
|
||||
import 'package:gitjournal/utils/logger.dart';
|
||||
import 'githost.dart';
|
||||
|
||||
@ -88,6 +90,10 @@ class GitHub implements GitHost {
|
||||
HttpHeaders.authorizationHeader: _buildAuthHeader(),
|
||||
};
|
||||
|
||||
if (foundation.kDebugMode) {
|
||||
print(toCurlCommand(url, headers));
|
||||
}
|
||||
|
||||
var response = await http.get(url, headers: headers);
|
||||
if (response.statusCode != 200) {
|
||||
Log.d("Github listRepos: Invalid response " +
|
||||
|
@ -3,11 +3,13 @@ import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/foundation.dart' as foundation;
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import 'package:gitjournal/utils.dart';
|
||||
import 'package:gitjournal/utils/logger.dart';
|
||||
import 'githost.dart';
|
||||
|
||||
@ -75,6 +77,10 @@ class GitLab implements GitHost {
|
||||
var url =
|
||||
"https://gitlab.com/api/v4/projects?simple=true&membership=true&order_by=last_activity_at&access_token=$_accessCode";
|
||||
|
||||
if (foundation.kDebugMode) {
|
||||
print(toCurlCommand(url, {}));
|
||||
}
|
||||
|
||||
var response = await http.get(url);
|
||||
if (response.statusCode != 200) {
|
||||
Log.d("GitLab listRepos: Invalid response " +
|
||||
|
@ -78,3 +78,12 @@ bool folderWithSpecExists(BuildContext context, String spec) {
|
||||
|
||||
return rootFolder.getFolderWithSpec(spec) != null;
|
||||
}
|
||||
|
||||
String toCurlCommand(String url, Map<String, String> headers) {
|
||||
var headersStr = "";
|
||||
headers.forEach((key, value) {
|
||||
headersStr += ' -H "$key: $value" ';
|
||||
});
|
||||
|
||||
return "curl -X GET '$url' $headersStr";
|
||||
}
|
||||
|
Reference in New Issue
Block a user