// RPC reply serializer, that should heppen in the end,
// because we pass errors in serialized form too
//


'use strict';


////////////////////////////////////////////////////////////////////////////////


module.exports = function (N) {

  N.wire.after('responder:rpc', { priority: 90 }, function rpc_serialize(env) {

    //
    // Set Content-Type and charset (override existing)
    //

    env.headers['Content-Type'] = 'application/json; charset=UTF-8';

    //
    // Status is always ok - errors are embedded into payload
    //

    env.status = N.io.OK;

    //
    // HEAD requested - no need for real rendering
    //

    if ('HEAD' === env.origin.req.method) {
      env.body = null;
      return;
    }

    //
    // Replace body with serialized payload
    //

    env.body = JSON.stringify({
      version:  N.runtime.version,
      error:    env.err,
      response: env.err ? null : env.response
    });
  });
};

@@ -316,23 +316,16 @@
 env) %7B%0A%0A
-    //%0A
     // S
@@ -372,24 +372,16 @@
 isting)%0A
-    //%0A%0A
     env.
@@ -442,23 +442,16 @@
 TF-8';%0A%0A
-    //%0A
     // S
@@ -500,32 +500,24 @@
 nto payload%0A
-    //%0A%0A
     env.stat
@@ -529,32 +529,148 @@
 N.io.OK;%0A%0A    //
+ Expose API path of the executed server method, e.g. 'forum.index'%0A    env.response.data.head.apiPath = env.method;%0A
 %0A    // HEAD req
@@ -705,24 +705,16 @@
 ndering%0A
-    //%0A%0A
     if (
@@ -793,23 +793,16 @@
 %0A    %7D%0A%0A
-    //%0A
     // R
@@ -841,16 +841,8 @@
 oad%0A
-    //%0A%0A
     

Fix pagination links on the RPC page navigation.