You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
import 'package:isekai_wiki/api/base_api.dart';
|
|
|
|
import 'package:isekai_wiki/global.dart';
|
|
|
|
|
|
|
|
class RestbaseApi {
|
|
|
|
static Uri getUri(String endpoint, {Map<String, dynamic>? search}) {
|
|
|
|
String url = Global.siteConfig.restfulApiUrl;
|
|
|
|
if (url.endsWith("/")) {
|
|
|
|
url = url.substring(0, url.length - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Uri.parse(url + endpoint).replace(queryParameters: search);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<String> get(String path, {Map<String, dynamic>? search}) async {
|
|
|
|
var uri = getUri(path, search: search);
|
|
|
|
return BaseApi.get(uri);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<Map> getJson(String path, {Map<String, dynamic>? search}) async {
|
|
|
|
var uri = getUri(path, search: search);
|
|
|
|
return BaseApi.getJson(uri);
|
|
|
|
}
|
|
|
|
}
|