dispatch method
Sends the given json
to the backend.
Implementation
@override
Future<bool> dispatch(String json) async {
if (_ingestToken.isEmpty == true) throw 'Humio ingest token is not defined';
if (ingestUrl.isEmpty == true) throw 'Humio ingest URL is not defined';
var dio = Dio();
Response<dynamic> response;
try {
response = await dio.post(
ingestUrl,
data: json,
options: Options(
contentType: 'application/json',
headers: {'Authorization': 'Bearer $_ingestToken'},
),
);
} on DioError catch (e) {
print('Humio log error: ${e.message}');
return false;
}
return response.statusCode == 200;
}