doWrite method

  1. @override
void doWrite(
  1. dynamic data,
  2. dynamic options, [
  3. dynamic callback
])
override

Performs the write.

Implementation

@override
void doWrite(data, options, [callback]) {
  // we must output valid javascript, not valid json
  // see: http://timelessrepo.com/json-isnt-a-javascript-subset
  var js = json
      .encode(data)
      .replaceAll(RegExp(r'\u2028'), '\\u2028')
      .replaceAll(RegExp(r'\u2029'), '\\u2029');

  // prepare response
  data = head + js + foot;

  super.doWrite(data, options, callback);
}