microgateway-plugins

3.3.3 • Public • Published

Plugins

Overview

This repo contains plugins for the microgateway-core project.

These plugins can be loaded into the microgateway calling the load plugin method

Building a plugin

must contain an init method which returns an object literal with all of the handlers

{
  init:function(config,logger,stats){
    return {
    onrequest:function(req,res,[options],next){
    },
    ...
    }
  }
}

init method must return an object with handler methods for each event

the available handlers are

  • on_request
  • ondata_request
  • onend_request
  • on_response
  • ondata_response
  • onend_response
  • onclose_response
  • onerror_response

The handler signature will look like :

function(sourceRequest,sourceResponse,[options],next){}
  • sourceRequest: the request from the northbound server;

  • sourceResponse the response to the northbound server;

  • options: are the full scope of fields you might need to operate on.

    	const options = {
        targetResponse: options.targetResponse,
        targetRequest: options.targetRequest,
        sourceRequest: options.sourceRequest,
        sourceResponse: options.sourceResponse,
        data: data
      };
  • you must call next with an error if you errored out like

next([err])

/microgateway-plugins/

    Package Sidebar

    Install

    npm i microgateway-plugins

    Weekly Downloads

    332

    Version

    3.3.3

    License

    Apache-2.0

    Unpacked Size

    1.1 MB

    Total Files

    105

    Last publish

    Collaborators

    • scottganyo
    • srinandan
    • dkoroth
    • keyurkarnik
    • indraneeldey