launch method

Future launch(
  1. String app, {
  2. dynamic payload,
})

Launches the specified app with an optional paylod

Implementation

Future launch(String app, {payload}) async {
  if (payload is Map) {
    var out = '';
    for (String key in payload.keys as Iterable<String>) {
      if (out.isNotEmpty) {
        out += '&';
      }

      out +=
          '${Uri.encodeComponent(key)}=${Uri.encodeComponent(payload[key].toString())}';
    }
    payload = out;
  }

  HttpClientResponse? response;
  try {
    response = await send('POST', '/apps/$app', body: payload);
    if (response.statusCode == 201) {
      return true;
    }
    return false;
  } finally {
    if (response != null) {
      await response.drain();
    }
  }
}