src/handlers.js
function onServerPreRequestHandler (ctx, err, value) {
  if (err) {
    if (err instanceof SuperError) {
      ctx._response.error = err.rootCause || err.cause || err;
    } else {
      ctx._response.error = err;
    }

    return ctx.finish();
  }

  // reply value from extension
  if (value) {
    ctx._response.payload = value;
    return ctx.finish();
  }

  // check if a handler is registered with this pattern
  if (ctx._actMeta) {
    ctx._extensions.onServerPreHandler.dispatch(ctx, (err, val) => {
      return onServerPreHandler(ctx, err, val);
    });
  } else {
    const internalError = new Errors.PatternNotFound(Constants.PATTERN_NOT_FOUND, ctx.errorDetails);
    ctx.log.error(internalError);
    ctx._response.error = internalError;

    // send error back to callee
    ctx.finish();
  }
}
function onServerPreRequestHandler (ctx, err, value) {
  if (err) {
    if (err instanceof SuperError) {
      ctx._response.error = err.rootCause || err.cause || err;
    } else {
      ctx._response.error = err;
    }

    return ctx.finish();
  }

  // reply value from extension
  if (value) {
    ctx._response.payload = value;
    return ctx.finish();
  }

  // check if a handler is registered with this pattern
  if (ctx._actMeta) {
    ctx._extensions.onServerPreHandler.dispatch(ctx, (err, val) => {
      return onServerPreHandler(ctx, err, val);
    });
  } else {
    const internalError = new Errors.PatternNotFound(Constants.PATTERN_NOT_FOUND, ctx.errorDetails);
    ctx.log.error(internalError);
    ctx._response.error = internalError;

    // send error back to callee
    ctx.finish();
  }
}
function onServerPreRequestHandler ( ctx , err , value ) { if ( err ) { if ( err instanceof SuperError ) { ctx . _response . error = err . rootCause || err . cause || err ; } else { ctx . _response . error = err ; } return ctx . finish ( ) ; } // reply value from extension if ( value ) { ctx . _response . payload = value ; return ctx . finish ( ) ; } // check if a handler is registered with this pattern if ( ctx . _actMeta ) { ctx . _extensions . onServerPreHandler . dispatch ( ctx , ( err , val ) => { return onServerPreHandler ( ctx , err , val ) ; } ) ; } else { const internalError = new Errors . PatternNotFound ( Constants . PATTERN_NOT_FOUND , ctx . errorDetails ) ; ctx . log . error ( internalError ) ; ctx . _response . error = internalError ; // send error back to callee ctx . finish ( ) ; } }
Is called before the server has received the request
Is called before the server has received the request